$page_on=15;//定义每页显示数 $pageNum=$_GET['pageNum']; //当前页数 $result = mysql_query("SELECT * FROM news"); $num=mysql_num_rows($result); $page=ceil($num/$page_on); //总页数 if($pageNum==0){ $pageNum=1; //当前页数为1 } if($pageNum>$page){ $pageNum=$page; //当前页数为最大页数 } //显示当前页面的内容 $sql="select * from news N left join sys_users S on N.news_sys_userid=S.sys_id order by news_time desc limit ".($pageNum-1)*$page_on.",".$page_on; $res=mysql_query($sql); $data=array(); while($row=mysql_fetch_array($res)){ $row['news_content']=mb_substr($row['news_content'],0,80); $row['news_time']=date('Y-m-d H:i:s',$row['news_time']); $data['list'][]=$row; } $total=$num; //总条数 $page=$page; //总页数 $current_page=$pageNum; //当前页数