This example is excerpted from phpbuilder.com
Slightly translated
//
$limit = 20; Number of lines displayed per page
$numresults =mysql_query ("select * from TABLE where YOUR CONDITIONAL here Order by WHATEVER");//Replace the SQL statement you need
$numrows =mysql_num_rows ($numresults);
Next determine if offset have been passed to script, if not use 0
if (empty ($offset)) {
$offset = 1;
}
Get query Results
$result =mysql_query ("Select Id,name,phone".
"From TABLE where YOUR CONDITIONAL here".
"ORDER by WHATEVER limit $offset, $limit");
Show Query Results now
while ($data =mysql_fetch_array ($result)) {
Insert the result you want to display here and the style
}
Display button
if ($offset!) =1) {//Bypass PREV link if offset is 1
$prevoffset = $offset-20;
print "prev \ n";
}
Number of pages calculated
$pages =intval ($numrows/$limit);
$pages now contains int of pages needed unless there are a remainder from division
if ($numrows% $limit) {
have remainder so add one page
$pages + +;
}
for ($i =1; $i <= $pages; $i + +) {//Show pages
$newoffset = $limit * ($i-1);
print "$i \ n";
}
Check to see if last page
if (! ( ($offset/$limit) = = $pages) && $pages!=1) {
Not last page so give NEXT link
$newoffset = $offset + $limit;
Print "Next page
\ n ";
}
?>
http://www.bkjia.com/PHPjc/315557.html www.bkjia.com true http://www.bkjia.com/PHPjc/315557.html techarticle PHP//This example is from phpbuilder.com//A little translation//sprming@netease.com $limit = 20;//The number of rows displayed per page $numresults =mysql_query (SELECT * FROM TABLE where YOUR CONDITIONAL here ...