Limit the display of records on each page from mysql
//A sample function that I made that will limit the number of
//rows from mysql to be display each page where $start is
//the starting row, $trows is the total number of rows and $rown
//is the number of rows to be display each page.
$rown ||$start<>intval(0))
{
$first="First";}
else
{
$first="First";
}
return $first;
}
function previous($start,$trows,$rown)
{
if ($start >= $trows-intval($trows%$rown)&&$trows>$rown||$start<>intval(0))
{
$prev=$start-$rown;
$previous="Previous";
}
else
{
$previous="Previous";
}
return $previous;
}
function next1($start,$trows,$rown)
{
if ($start < ($trows-intval($trows%$rown))&&(($start+$rown)-$trows<>"0"))
{
$next=$start+$rown;
$next="Next";
}
else
{
$next="Next";
}
return $next;
}
function last($start,$trows,$rown)
{
if ($start < $trows-intval($trows%$rown)&&(($start+$rown)-$trows<>"0"))
{
if (($rem=$trows%$rown)==0){$rem=$rown;}
$last=intval($trows-$rem);
$last="Last";
}
else
{
$last="Last";
}
return $last;
}
//end of the functions
mysql_connect($host,$user,$password);
mysql_select_db($db);
$query="select * from $tbl";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);//total number of rows equal to $trows;
if ($start=="")
{$start=0;}
$query="$query limit $start,$rown"; //limit output $rown=5 rows starting $start
$result=mysql_query($query);
print"
Field1
Field2
Field3
Field4
Field5
";
while ($row=mysql_fetch_array($result))
{
print"