| The code is as follows |
Copy Code |
| function GetPage ($talbe, $choose, $url) { Global $page, $db, $sortname; $query = $db->query ("select * from $talbe $choose"); $total = $db->num_rows ($query); $totalpage =ceil ($total/25); $nextpage = $page +1; $uppage = $page-1; if ($nextpage > $totalpage) $nextpage = $totalpage; if ($uppage <1) $uppage = 1; $showpage = "Total <b><font color= ' #FF0000 ' > $total </font></b> Records, <b><font color= ' FF0000 ' > $totalpage </font></b> page, currently <b><font color= ' #FF0000 ' > $page </font></b > Page <b><font color= ' #FF0000 ' >◇</font></b><a href= '? $url &page= $uppage &sortname=$ Sortname ' > Prev </a><b><font color= ' #FF0000 ' >◇</font></b><a href= '? $url & page= $nextpage &sortname= $sortname ' > next page </a><font color= ' #FF0000 ' ><b>◇ '; return $showpage; } function Reto ($msg, $url = ' ") { Global $comeurl; if (! $url) $url = $comeurl; Return "<table width= ' 100% ' cellspacing= ' 1 ' cellpadding= ' 3 ' bgcolor= ' #CCCCCC ' > <tr bgcolor= ' #FFFFFF ' > <td> <div align= ' center ' ><font size= ' +6 ' ><b><font size= ' 5 ' ><a href= ' $url ' ><font color= ' #993300 ' > $msg </font></a></font></b></font></div> </td> </tr> </table> "; } |
Through the page of the code we can see the original PHP page is very simple, as long as get[page] page, the current page, and then use the $page* $pagesize to start, after the $pagesize to the end of OK. The MySQL statement is $sql = "SELECT * FROM t limit $page * $pagesize, $pagesize";
Site original tutorial, reprinted annotated Source Www.111cn.net