I have a web page form my son. I built it with html. I am trying to learn php. I am trying to redo the website with the help of php to make it easier for me to update. I am using xammp to test everything before loaded to server. I have AddHandler application/x-httpd-php .html in httpd.conf. All of the code works correctly when each page is saved as .php files. My problem happens when I try to retrieve the page content from MySQL. It does not recognize the attributes of objects. All the pages retrieved from MySQL work as long as there is no reference to an attribute. What am I doing wrong, or what do I need to change? Any help would be greatly appreciated. Let me know what other info would help.
I will attach code and what the DOM is showing.
Here is the code for index page
[php]
<?php require_once("../includes/initialize.php"); ?> <?php $layout_context = "public"; ?> <?php include("../includes/layouts/header.php"); ?> <?php Page::find_selected_page(true); ?> <nav>
<?php echo public_navigation($current_headings, $current_page, $current_sub_page); ?>
</nav>
<div id="banner">
</div>
<?php echo ($current_headings["content"]); ?>
<?php echo ($current_page["content"]); ?>
<?php echo ($current_sub_page["content"]); ?>
<?php include("../includes/layouts/footer.php"); ?>[/php]
This is code from f12 debugger when page loads with content from MySQL.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="Stlye/GQ2.css" media="all" rel="stylesheet" type="text/css" />
<title>GQ Hart </title>
</head>
<body>
<div class="wrapper">
<header>
<div class="top-bar">
<p><a href="../public/login.php">LOGIN</a></p>
</div>
<div class="left-title">
<h1>GQ HART</h1>
<p>My Life</p>
</div>
</header> <nav>
<ul class="headings"><li><a href="index2.php?headings=1">HOME</a><ul class="pages"></ul></li><li><a href="index2.php?headings=2">TRAVELS</a><ul class="pages"><li><a href="index2.php?page=1">Inside The U.S.</a><ul class="sub_pages"></ul></li><li class="selected"><a href="index2.php?page=2">Outside The U.S.</a><ul class="sub_pages"></ul></li></ul></li><li><a href="index2.php?headings=3">SPORTS</a><ul class="pages"><li><a href="index2.php?page=3">Rodeo</a><ul class="sub_pages"><li><a href="index2.php?sub_page=1">2014</a></li><li><a href="index2.php?sub_page=2">2015</a></li></ul></li><li><a href="index2.php?page=4">Football</a><ul class="sub_pages"></ul></li></ul></li><li><a href="index2.php?headings=4">OTHER ACTIVITIES</a><ul class="pages"></ul></li></ul> </nav>
<div id="banner">
</div>
<?php
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
$per_page = 3;
$total_count = Media::count_all();
$pagination = new Pagination($page, $per_page, $total_count);
$sql = "SELECT * FROM media ";
$sql .= "LIMIT {$per_page} ";
$sql .= "OFFSET {$pagination->offset()}";
$medias = Media::find_by_sql($sql);
?>
<section id="content">
<article id="january">
<video controls>
<source src="Media/Rodeo2015/HardeeJan.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
<hgroup>
<h2>January</h2>
<h3>Hardee</h3>
</hgroup>
<p>
My second full ride at Hardee this season.
</p>
</article>
<article>
<video controls>
<source src="Media/Rodeo2015/TopHandJan.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
<hgroup>
<h3>Top Hand</h3>
</hgroup>
<p>
Gavin vs Oreo.
</p>
</article>
<article id="february">
<video controls>
<source src="Media/Rodeo2015/ArcadiaFeb.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
<hgroup>
<h2>February</h2>
<h3>Arcadia</h3>
</hgroup>
<p>
Another full ride in Arcadia.
</p>
</article>
<article>
<video controls>
<source src="Media/Rodeo2015/CircleSFeb.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
<hgroup>
<h3>Circle S</h3>
</hgroup>
<p>
One of the biggest bucking steers I have ridden.
</p>
</article>
<?php foreach($medias as $media):
if (strpos($media->type, 'image') !== false) { ?>
<article>
<a href="mediapage.php?id=<?php echo $media->id ?>">
<img src="<?php echo $media->image_path(); ?>" width="200" />
</a>
<hgroup>
<h3><?php echo $media->caption ?></h3>
</hgroup>
<p><?php echo $media->caption ?></p>
</article>
<?php } else { ?>
<article>
<video controls>
<source src="<?php echo $media->image_path(); ?>">
Your browser does not support HTML5 video.
</video>
<hgroup>
<h3><?php echo $media->caption; ?></h3>
</hgroup>
<p>
One of the biggest bucking steers I have ridden.
</p>
</article>
<?php } ?>
<?php endforeach; ?>
<div id="pagination" style="clear: both;"/>
<?php
if($pagination->total_pages() > 1) {
if($pagination->has_previous_page()) {
echo "<a href=\"index.php?page=";
echo $pagination->previous_page();
echo "\">« Previous</a> ";
}
for($i=1; $i <= $pagination->total_pages(); $i++) {
if($i == $page) {
echo " <span class=\"selected\">{$i}</span> ";
} else {
echo " <a href=\"index.php?page={$i}\">{$i}</a> ";
}
}
if($pagination->has_next_page()) {
echo " <a href=\"index.php?page=";
echo $pagination->next_page();
echo "\">Next »</a> ";
}
}
?>
<table>
<tr class="head">
<th>Rodeo</th>
<th>Oct</th>
<th>Nov</th>
<th>Dec</th>
<th>Jan</th>
<th>Feb</th>
<th>Mar</th>
<th>Apr</th>
<th>May</th>
</tr>
<tr class="odd">
<th>Arcadia</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>9</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>Circle S</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td></td>
<td>0</td>
</tr>
<tr class="odd">
<th>Hardee</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>10</td>
<td>0</td>
<td>9</td>
<td>0</td>
</tr>
<tr>
<th>Top Hand</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<caption>2014-2015 Rodeo Season Points</caption>
</table>
</section>
<aside>
<section>
<h2>Rodeos</h2>
<a href="http://www.circlesrodeo.com/" target="_blank">Circle S</a>
<a href="http://www.arcadiayouthrodeo.com/" target="_blank">Arcadia</a>
<a href="http://www.tophandrodeo.com/" target="_blank">Top Hand</a>
<a href="http://www.hardeecountyyouthrodeo.com/" target="_blank">Hardee</a>
</section>
</aside>
<footer>
<p> © 2015 GQ Hart</p>
</footer>
</div><!-- .wrapper -->
</body>
</html>
Not sure how to attach photo of DOM but line 33 is where problem starts after pagination-> the php turn off
and just becomes plain text, then again at 88 and so on.