初学者能容易看懂的php连接mysql分页代码
高手写的代码如果水平不够不容易看懂,下面这段代码适合水平稍低的初学者,很容易!!!
<?php
mysql_connect('localhost','root','password');//***********
mysql_select_db('databasename'); //连接数据库,设置文字格式
mysql_query("SET NAMES gbk"); //************
$page_num=2;
echo $page_start=empty($_GET['page_no'])?1:($_GET['page_no']*$page_num);
echo "<br>";
$total=mysql_query("select*from tablename limit $page_start,$page_num");//提取数据
while($perpage=mysql_fetch_object($total))
{echo $perpage->id;
echo $perpage->nick;
echo $perpage->account."<br>";}
echo "<a href=\"show_me.php?page_no=".($_GET['page_no']-1)."\">"."上一页"."</a>"; //分页链接
echo "<a href=\"show_me.php?page_no=".($_GET['page_no']+1)."\">"."下一页"."</a>";
?>
是不是很简单!!!