Hi everyone, I am like so proud of myself because I am building a php web page. I get stuck now and then, but eventually get it after two or three days:(
I have one big problem that I have put on the back burner for a while and I have been focusing on my other bugs and issues.
First I will explain how the page initially look and how I made it and my main goal for the look.
1. first the page images was vertical (position goin downward)
2. Then I position it going horizontal (left to right) **which is good I wanted it to go to left to right, but I wanted 3 images per line/row on each page. Not three image per page.
When I increased the record per page everything is going horizontal(all the way to the right).
Is there any way that I can changed my code to display the images still horizontal but 3 image per row, 6 images per page. Like this below?
image image image
image image image
image image image
next page
Thank you in advance
<?php
function showproducts($catid, $page, $currentpage, $newpage)
{
$query = "Select count(prodid) from products where catid = $catid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if ($row[0] == 0)
{
echo "<h2><br>Sorry, there are no products in this category</h2>\n";
}
else
{
$thispage = $page;
$totrecords = $row[0];
$recordsperpage = 3;
$offset = ($thispage - 1) * $recordsperpage;
$totpages = ceil($totrecords / $recordsperpage);
echo "<table width=\"100%\" cellpadding=\"1\" border=\"0\"><tr>\n";
$query = "SELECT * from products WHERE catid=$catid LIMIT $offset,$recordsperpage";
$result = mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$prodid = $row['prodid'];
$description = $row['description'];
$price = $row['price'];
$quantity = $row['quantity'];
$onsale = $row['onsale'];
echo "<td>\n";
echo "<img src=\"showimage.php?id=$prodid\" width=\"150\" height=\"150\">\n";
echo "<a href=\"$newpage&id=$prodid\">$description\n";
echo "$" . $price . "\n";
if ($onsale)
echo "On sale!\n";
else
echo " \n";
echo "</td>\n";
}
echo "</tr></table>\n"; // Code to implement paging
if ($thispage > 1)
{
$page = $thispage - 1;
$prevpage = "<a href=\"$currentpage&cat=$catid&page=$page\">Previous page</a>";
} else
{
$prevpage = " ";
} if ($thispage < $totpages)
{
$page = $thispage + 1;
$nextpage = " <a href=\"$currentpage&cat=$catid&page=$page\">Next page</a>";
} else
{
$nextpage = " ";
} if ($totpages > 1)
echo $prevpage . " " . $nextpage; }
}
?>