php mysql break after retreiving last db row
Posted: Sun Feb 08, 2015 2:00 pm
hi everyone,
I'm struggling with getting inserting a break after retrieving the final row from the db. I've attached a screenshot as well so you can see the issue. There should be a simple fix for this. I have a 'clear: both' on the 'hr.style-two' and i even put an extra '<br clear="all" />' after the hr and that still doesn't push the next product picture to the next line. Any help would be appreciated. Thanks.
I'm struggling with getting inserting a break after retrieving the final row from the db. I've attached a screenshot as well so you can see the issue. There should be a simple fix for this. I have a 'clear: both' on the 'hr.style-two' and i even put an extra '<br clear="all" />' after the hr and that still doesn't push the next product picture to the next line. Any help would be appreciated. Thanks.
Code: Select all
<?php
$string = "SELECT id,prod_name,prod_price,prod_dimensions,prod_paypalcode,filename1,filename2 FROM products ORDER BY prod_name ASC";
$query = mysql_query($string) or die (mysql_error());
$num_rows = mysql_num_rows($query);
print "<div id='titles_smaller'>There are <b>$num_rows product(s)</b></div><br />";
if($num_rows>0) {
echo "<br />";
$result = mysql_fetch_array($query);
if($result==true) {
do {
echo "<div style='width:140px; float:left; margin-right: 30px; margin-bottom: 10px; '>";
if (empty($result['filename1'])) { } else { ?> <a class="example-image-link" href=uploads/images/products/<?php echo $result['filename1']; ?> data-lightbox="example-1"><img class="example-image" src="uploads/images/products/<?php echo $result['filename1']; ?>" alt="thumb-1" style="height:160px;" /></a> <?php } ;
echo "</div>";
echo "<div style='width:140px; float:left; margin-right: 30px; margin-left: 30px; margin-bottom: 10px; '>";
if (empty($result['filename2'])) { } else { ?> <a class="example-image-link" href=uploads/images/products/<?php echo $result['filename2']; ?> data-lightbox="example-1"><img class="example-image" src="uploads/images/products/<?php echo $result['filename2']; ?>" alt="thumb-1" style="height:160px;" /></a> <?php } ;
echo "</div>";
echo "<div style='width:140px; float:left; margin-right: 10px; margin-left: 20px; margin-bottom: 10px; ' class='clear'>";
echo $result['prod_name'] . "<br />";
echo $result['prod_price'] . "<br />";
echo $result['prod_dimensions'] . "<br />";
echo "<div style='width:140px; float:left; clear:both; margin-right: 30px; margin-bottom: 10px; ' >";
echo $result['prod_paypalcode'] . "<br />";
echo "<hr class='style-two'>";
echo "<br clear='all' />";
echo "</div>";
echo "</div>";
}
while($result = mysql_fetch_array($query));
}
} else {
echo "<div id='titles_smaller'>No products available.</div><br />";
}
?>