This is the code I use:
$messages = mysql_query("select * from messages where 1 order by id2 desc LIMIT $start,50" , $link)
The important bit there is the LIMIT $start,50
This only selects 50 results, beginning from $start which will be defined in the URL in this code:
$num=0;
$pn=0;
echo "<br>Pages: ";
$tmsgs=mysql_num_rows(mysql_query("SELECT * FROM messages where 1"));
if ($start<>0)
{
$numap=$start-50;
echo "<a href='?start=$numap'>";} echo"Previous Page</a> | "; //changelink
while($tmsgs-$num>0){
$pn++;
if ($num<>$start)
{
echo "<a href='?start=$num'>$pn</a> | "; //changelink
}
else
{
echo "$pn | ";}
$num+=50;
}
$numa=$start+50;
if ($tmsgs-$numa>0)
{
echo"<a href='?start=$numa'>";} echo"Next Page</a>"; //changelink
}}
Insert that bit of code where you want the page links to show. If you need anyother query strings to be carried you need to add them on each line where I've written changelink.
Let me know if it works!