Greetings all, I am working on getting some pagation code for my website perfected. I didn't write the code, Batman posted it awhile back and im really happy with it...It works pretty good, similiar to google.com but i can't figure out a way to get the page numbers to be "highlighted" after a user clicks on sed page number. Example, lets say a query generates 107 records, at limits the results to 10 records per "page". Thats 11 pages so the pagaiation navigation looks like this
<< Previous 1 2 3 4 5 6 7 8 9 10 11 Next >>
If the user clicks on "3" i would like the links to possible "unhyperlink" the 3 or bold it or whatever, just so its easy for someone to tell which page they are on. Yes im also doing page numbers but id also like the links to function dynamically.
here is the snipit that of code that builds the page numbers:
// Generate page links for 1 2 3 4 5 6 7 8 9 10
while ($a > 0)
{
echo "<a href=\"" . $PHP_SELF . "?start=" . $b . "&catagory=$catagory&subcatagory=$subcatagory&city=$city\"><font color=0000ff>".$c."</a>\n</font></b>";
$a--;
$c++;
$b = $b + 10;
$count++;
if ($count >= 15)
{
$count = 0;
print "<br>";
}
}
Here is the whole !#:
$query = "SELECT count(*) as count FROM phone_wi_$city WHERE catagory = '$catagory' && subcatagory = '$subcatagory' ORDER BY preid desc, $sort $updown";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
$count = 0;
if($start > 0)
{
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 10) . "&catagory=$catagory&subcatagory=$subcatagory&city=$city\"><b><font color=0000ff><< Previous</b></font></a>\n";
echo "|\n";
}
if($start <= 0)
{
echo "<font color=000000><b><< Previous\n</font></b>";
echo "|\n";
}
$a = ceil($rowcount2 / 10);
$b = 0;
$c = 1;
// Generate page links for 1 2 3 4 5 6 7 8 9 10
while ($a > 0)
{
echo "<a href=\"" . $PHP_SELF . "?start=" . $b . "&catagory=$catagory&subcatagory=$subcatagory&city=$city\"><font color=0000ff>".$c."</a>\n</font></b>";
$a--;
$c++;
$b = $b + 10;
$count++;
if ($count >= 15)
{
$count = 0;
print "<br>";
}
}
if($numrows > ($start + 10))
{
echo "|\n";
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 10) . "&catagory=$catagory&subcatagory=$subcatagory&city=$city\"><font color=0000ff><b> Next >></font></b></a>\n";
}
else if($numrows <= ($start + 10))
{
echo "|\n";
echo "<font color=000000><b>Next >></font></b><BR>\n";
}
Thanks in advance!