PHP Paging code error, consult a master. (Only the last 27 points left)
The result is the first page that displays only the contents of the database, and clicking the next page still stays on the first page.
$pages =ceil ($count/$list _num);
echo "
|
Total ". $pages." Page | "; if ($offset) {$preoffset = $offset-$list _num;print "
Previous page | ";} else {echo '
Previous page | ";} $newoffset = $offset + $list _num; if ($pages!=0) && (($newoffset/$list _num)! = $pages)) {print ("
Next page | ");} else{echo "
Next page | ";} $pageno = ($offset/$list _num) +1;echo "
ThePage |
|
";
?> PHP page PHP page
Share to:
------Solution--------------------
As for the SQL statement of the database, I'm not quite sure how it was written.
Typically select * from ' table ' ORDER BY id DESC LIMIT 1 $offset * $count/$list _num, ($offset + 1) * $count/$list _num
The following code has been tested with my own database and can be run
!--? php
if ($_get[offset]) {
$offset = $_get[offset];
}
$count = 100;
$list _num = 5;
$pages =ceil ($count/$list _num);
Echo
There are currently ". $count." Record |
total. "$pages." Page | "; if ($offset) {$preoffset = $offset-1; Print "
";} else {echo " |
previous page | "; } $newoffset = $offset +1;//$list _num; if ($pages!=0) && (($newoffset/$list _num)! = $pages)) {print ("
"); |