results on multiple pages
| From: | James Kupernik | Date: | Tue, 16 Apr 2002 20:20:28 +0000 |
| Subject: | results on multiple pages | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-18565@lists.php.net to get a copy of this message | ||
I am retrieve records from my MySQL table and I want to display the results
12 per page along with allow for a sort. I was just send a query to the
table with a limit each time, but it didn't sort all the records, so I need
to load all the results into a table to sort then display. Here is what I
have for code....
<?php
Mysql_connect("localhost","user","pass");
mysql_select_db("countryloft");
if (!$nextpg) {
$i = 0;
} else {
$i = $i + 12;
}
$prodTbl = mysql_query("select * FROM countryloft WHERE category LIKE
'%folk%' ORDER BY displayorder");
$num_results = mysql_num_rows($prodTbl);
$itemsPerPage = 12;
echo "<table>";
$mycolumn = 1;
$maxcolumn = 3;
//loop table until end of results
for ($i=$i; $i < $itemsPerPage; $i++)
{
$row = mysql_fetch_array($prodTbl);
echo "<td width=200 align=center><a
href=productinfo.php?prodID=".$row['record']."><img
src=http://www.thecountryloft.com/countryloft/yellowpics/".$row['image3']."
border=0>";
echo "<br><font size=2>".$row['title']."</font>";
echo "<br><font
size=2>".$row['price']."</font></td>\n";
if ($mycolumn == $maxcolumn)
{
echo "</tr>";
}
$mycolumn = $mycolumn + 1;
if ($mycolumn > $maxcolumn)
{
$mycolumn = 1;
}
}
echo "</table>\n";
echo "<a href=$PHP_SELF?i=$i&nextpg=yes>Next Page</a>";
?>
Any help would be great!!
Thanks!