//数据库连接
$my_db = mysql_connect("localhost","root","");
mysql_select_db("model", $my_db);
mysql_query("set names 'utf8'");
$page = isset($_GET['page'])?intval($_GET['page']):0;//第几页值
$shownum = 2;//每页显示数量
$limit = $page * $shownum;//查询开始数
$sql = "select * from web_news order by id desc limit $limit,$shownum";
$query = mysql_query($sql);
$rows = array();
while($row = mysql_fetch_assoc($query))
{
$rows[] = $row;
}
$sql_count = "select * from web_news";
$total = mysql_num_rows(mysql_query($sql_count));//总数量
$pagenum = ceil($total/$shownum);//总共页数
$pages = '';
$pages .='总共'.$total.'信息'.' 共'.$pagenum.'页,每页'.$shownum.'条信息';
$pages .=''.'首页'.'';
if($page <= 0){
$pages .=''.'上一页'.'';
}else{
$pages .=''.'上一页'.'';
}
for($i=0;$i
if($page == $i){
$pages .=''.($i+1).'';
}else{
$pages .=''.($i+1).'';
}
}
if($page >= ($pagenum-1)){
$pages .=''.'下一页'.'';
}else{
$pages .=''.'下一页'.'';
}
$pages .=''.'末页'.'';
?>
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
分页.pages a{ padding:5px 8px 5px 8px; border:#999999 1px solid; margin-left:5px;}
.pages a.hover{ color:#FF0000;}