How to realize paging in PHP+ajax
This article is to share with you about how PHP+ajax implements paging. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The details are as follows:
The HTML code is as follows:
Title
The php code is as follows:
Header ("Content-type: text/html;charset=GBK"); / / $link=mysql_connect ('localhost','root','root'); mysql_select_db (' test'); mysql_query ("SET NAMES 'GBK'"); $num=5;// displays 5$ sql= "select * from article" per page; / / how many records are there in total $resultt=mysql_query ($sql); / / get the total number of database records $total=mysql_num_rows ($result); and how many pages are there in echo $total;//? / / get the current page $currentPage=isset ($_ GET ['page'])? intval ($_ GET [' page']): 1 banner / number of query entries $offset= ($currentPage-1) * $num;// next page $nexpage= ($currentPage==$pagecount?0:$currentPage+1); / / previous page $prepg=$currentPage-1;$url='ajax.php';// query information $strSQL= "select * from article limit $offset,$num"; $pagecontrol= "current number". $currentPage. " Page "; $pagecontrol.=" total ". $pagecount." Page "; $pagecontrol.=" Home "; if ($prepg) $pagecontrol.=" previous "; else $pagecontrol.=" previous "; if ($nexpage) $pagecontrol.=" next "; else $pagecontrol.=" next "; $pagecontrol.=" Last Page "; $result1=mysql_query ($strSQL); echo"; echo "; echo" numbered title News Type "; echo"; while ($row=mysql_fetch_array ($result1)) {echo "" Echo "$row [id] $row [title] $row"; echo "";} echo ""; echo ""; echo $pagecontrol; thank you for reading! This is the end of the article on "how to achieve paging in PHP+ajax". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!