本文实例讲述了PHP+ajax分页实现方法。分享给大家供大家参考,具体如下:
HTML代码如下:
<meta http-equiv="Content-Language" content="en" /><meta name="GENERATOR" content="PHPEclipse 1.0" /><meta http-equiv="Con<div>本文#来源gaodai.ma#com搞##代!^码7网</div><pre>搞代gaodaima码
tent-Type” content=”text/html; charset=GB2312″ />
php代码如下:
header("Content-type: text/html;charset=GBK");//$link=mysql_connect('localhost','root','root');mysql_select_db('test');mysql_query("SET NAMES 'GBK'");$num=5;//每页显示5条$sql="select * from article ";//总共有多少记录$resultt=mysql_query($sql);//获取数据库总记录数$total=mysql_num_rows($result);echo $total;//总共有多少页$pagecount=$total/$num;//获取当前页$currentPage=isset($_GET['page'])?intval($_GET['page']):1;//查询条数$offset=($currentPage-1)*$num;//下一页$nexpage=($currentPage==$pagecount?0:$currentPage+1);//"; else $pagecontrol.="下一页";$pagecontrol.="尾 页";$result1=mysql_query($strSQL);echo "<table border="1" width="100%">";echo "<tr>";echo "<td>编 号</td><td>标 题</td><td>新闻类型</td>";echo "</tr>";while($row=mysql_fetch_array($result1)){ echo "<tr>"; echo "<td>$row[id]</td><td>$row[title]</td><td>$row[classname]</td>"; echo "</tr>";}echo "</table>";echo "<br />";echo $pagecontrol;
希望本文所述对大家PHP程序设计有所帮助。