Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize paging in PHP+ajax

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report