Greetings all, I finally got pageation to work with my site. When someone queries the system and it returns 10 or more results the pages as well as next | previous buttons are generated so you can view 10 per page. Anyway now id like to get numbered links generated similiar to what google does, so if your search returns 150 results these buttons would be generated:
< Previous 1 2 3 4 5 6 7 8 9 10 Next >
clicking on 3 would bring up page 3 which contains results 21-30
and the links on the bottom of the page would then read
< Previous 3 4 5 6 7 8 9 10 11 12 Next >
Because there would be a maximum of 10 links on the nav bar...
Exactally like the default google interface if that makes any sense. Any psudo code or logic ideas would be AWESOME on this! Here is my code:
<?php
require'servars.php';
if(!isset($start)) $start = 0;
$connect = mysql_connect("$dbhost", "$dbuser", "$dbpass");
mysql_select_db($dbname);
$query = "SELECT * FROM $table11 LIMIT " . $start . ", 10";
$result = mysql_query($query);
$rowcount = mysql_num_rows($result);
if ($rowcount >= 1)
{
include ("adhead.php");
print "<h5>$rowcount Classifieds Online</center></h5>";
print "<table border=0 width=135% cellspacing=0 cellpadding=0>";
print "<TR>";
$colorshift = white;
$track = 0;
while ($row = mysql_fetch_array ($result))
{
print "<table border=0 width=135% cellspacing=0 cellpadding=0>";
print "<TR>";
if ($colorshift == white)
{
$color = ffffff;
$colorshift = gray;
}
else
{
$colorshift = white;
$color = eeeeee;
}
print "<td width=20% bgcolor=#$color>";
print "<img src=public/images/$row[picture].jpg width=75 height=75>";
print "</td>";
print "<td width=20% bgcolor=#$color>";
print "<p align=center><font size=2 color=#0000FF><b><a href=$row[id].html><font color=#0000ff>$row[name]</b></font></p>";
print "</td>";
print "<td width=20% bgcolor=#$color>";
print "<p align=center><font size=2 color=#0000FF><b>$row[catagory]</b></font></p>";
print "</td>";
print "<td width=20% bgcolor=#$color>";
print "<p align=center><font size=2 color=#0000FF><b>$row[price]</b></font></p>";
print "</td>";
print "<td width=20% bgcolor=#$color>";
print "<p align=center><font size=2 color=#0000FF><b>$row[date]</b></font></p>";
print "</td>";
print "</tr>";
print "</table>";
$track++;
}
print "<TABLE BORDER=0 WIDTH=135%>";
print "<TR>";
print "<TD ROWSPAN=2 WIDTH=200>";
print "</TD>";
print "<TD>";
print "</TD>";
print "</TR>";
print "<TR><TD ALIGN=left>";
print "<br>";
print "</A>";
print "</TABLE>";
$query = "SELECT count(*) as count FROM classified";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 10) .
"\">Previous</a><BR>\n";
if($numrows > ($start + 10))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 10) .
"\">Next</a><BR>\n";
}
else
{
include ("adhead.php");
print "<TABLE BORDER=0 WIDTH=400>";
print "<TR>";
print "<TD ROWSPAN=2 WIDTH=100>";
print "</TD>";
print "<TD>";
print "</TD>";
print "</TR>";
print "<TR><TD ALIGN=center>";
print "<h3>No records matching your information were found<h3>";
print "</A>";
print "</TABLE>";
}
include("footer.php");
mysql_free_result ($result);
?>