Learning purpose: Make a paging display
The key is to use the limit in the SQL statement to limit the number of records displayed. We need a variable $page that records the current page, and we also need the total number of records $num
For $page, if there is no one, let it = 0, if there is
$execc="select count(*) from tablename ";
$resultc=mysql_query($execc);
$rsc=mysql_fetch_array($resultc);
$num=$ rsc[0];
This way you can get the total number of records
ceil($num/10)) If there are 10 records on a page, this is the total number of pages
So you can write it like this
if(empty($_GET['page']))
{
$page=0;
}
else
{
$page=$_GET[' page'];
if($page<0)$page=0;
if($page>=ceil($num/10))$page=ceil($num/10)-1;/ /Because page starts from 0, so -1
}
In this way, $exec can be written like this $exec="select * from tablename limit ".($page*10).",10 ";
//One page has 10 records
The last thing we need to do is a few connections:
FirstPage< /a>
PrevPage
NextPage
LastPage
This is a general idea. Can you think about how to optimize it? Having said that today, I will talk about some issues to pay attention to tomorrow.