I am using a while loop to echo images and titles to a webpage.
My problem is that the last image being echoed (whether it is image number 2 or 6) is placed below the footer when displayed on the page: Image example
For whatever reason the div "footer" is being added in the middle of the content div and I have no idea why. Why would it be moving into a div it doesn't belong in, and specifically right after the second to last item listing?
Thank you much in advance!
Loop:
$query = ("SELECT * FROM photos");
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
while ($i<$num) {
$name = mysql_result($result, $i, 'Name');
$price = mysql_result($result, $i, 'Price');
$price = '$'.$price;
$description = mysql_result($result, $i, 'Description');
$location = mysql_result($result, $i, 'Location');
$id = mysql_result($result, $i, 'id');
$status = mysql_result($result, $i, 'Status');
echo "<table class='item'>
<tr class='name'>
<td><h2>" . $name . "</h2><h4>" . $type = ($status == "SOLD" ? $status : $price) . "</h4></td>
</tr>
<tr class='imagelocation'>
<td><img src='" . $location . "' class='image'></td>
<td class='itemdescription'>" . $description . " " . $price . "</td>
</tr>
";
$i++;
}
?>
</div>
</div>
<div id="footer">
<h5>For additional information, please <a href="contact.html">contact me</a>. <br /> <br />Copyright © </h5>
</div>
<!-- end #footer -->
</body>
Outputted HTML:
<div class="item_list">
<table class="item">
<tbody><tr class="name">
<td><h2>Curtis</h2><h4>$8291.23</h4></td>
</tr>
<tr class="imagelocation">
<td><img src="images/HDR1.jpg" class="image"></td>
<td class="itemdescription">Lorem</td>
</tr>
</tbody></table>**<div id="footer">
</div>**<table class="item">
<tbody><tr class="name">
<td><h2>Vienna wall clock</h2><h4>SOLD</h4></td>
</tr>
<tr class="imagelocation">
<td><img src="images/image001.jpg" class="image"></td>
<td class="itemdescription"> </td>
</tr>
</tbody></table></div>
echo "<table class='item'>
<tr class='name'>
<td><h2>" . $name . "</h2><h4>" . $type = ($status == "SOLD" ? $status : $price) . "</h4></td>
</tr>
<tr class='imagelocation'>
<td><img src='" . $location . "' class='image'></td>
<td class='itemdescription'>" . $description . " " . $price . "</td>
</tr></table>
";