PHPMYSQL分页原理 1、sql语句中的limit用法selectfromtablelimit开始位置(从0开始),操作数selectfromtablelimit0,20取前20个数据selectfromtablelimit10,20取11条到30条数据 2、学习分页的一种公式 (1)分页原理 所谓的分页显示,也就是将数据库中的结果集,以一定的条数显示出来。 (2)如何分段(以10条数据为单位) 前10条记录:selectfromtablelimit0,10 第11条到20条:selectfromtablelimit10,10 第21条到30条:selectfromtablelimit20,10 (3)得到公式 (当前页数1)每页条数,每页条数selectfromtablelimit(Page1)PageSize,PageSize; 3、实例代码lt;?php分页效果2include(conn。php);serverurlSERVER〔REQUESTURI〕;从浏览器得到URLparseurlparseurl(serverurl);将浏览器得到的URL转换为数组urlparseurl〔path〕;得到url地址字符串pagesize5;设置分页数目sql1selectfromarticle;query1mysqlquery(sql1);nummysqlnumrows(query1);得到查询的表的所有数据条数size(int)(numpagesize)1;得到总页数pageindex0;if(!empty(GET〔page〕)){pageindexGET〔page〕;取得页面索引}pageindex5;sql2select(pageindex);得到分页查询的sql语句echosql2;query2mysqlquery(sql2);while(datamysqlfetcharray(query2)){echoh2标题:。data〔title〕。h2。data〔date〕。brb。data〔contents〕。bhr;}?lt;?phpfunctionselect(index){sqlselectselectfromarticlelimitindex,5;returnsqlselect;}?