Hi
I think i'm close to my answer but I just can't quite figure it out. Anyway, i'm pulling result from a table 5 at a time and wanna have a next and previous button. This is working fine, next I wanted to add a number for each page, which I have also done, but I dunno how to make each page number direct to the right set of results. heres the code:
<?
$db = mysql_connect("localhost", "user","pass");
mysql_select_db("database",$db);
if(!$rowstart) $rowstart=0;
$result = mysql_query("SELECT * FROM links LIMIT $rowstart,5");
$result2 = mysql_query("SELECT * FROM links");
while ($myrow = mysql_fetch_row($result))
{
for ($i=0; $i<mysql_num_fields($result); $i++)
echo $myrow[$i] . " ";
echo "<br>";
}
if ($rowstart>$numrows)
{
$back = $rowstart-5;
echo "<a href='thispage.php?rowstart=".$back."'>< Previous</a>";
}
echo "|";
$numrows=mysql_num_rows($result2);
if($rowstart+5<$numrows)
{
$forward = $rowstart+5;
echo "<a href='thispage.php?rowstart=".$forward."'> Next Page > </a>";
}
$count = 0;
$pages = $numrows/5;
for($count=0; $count<$pages; $count++)
{
echo " <a href='thispage.php?rowstart='>".$count."</a> ";
}
?>
So lets say there are 90 results in the database, i'd get:
result 1
result 2
result 3
result 4
result 5
Next > 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
So if i click on 6, it i will show the results of limit 30.
Hope you understand, please help!
thanks
Ant