下面我们来看看我自己写的一个简单的php分页代码哦,其实在php中分页比较在asp中分页容易的多,这也可能是因为mysql有强大的功能的吧,这样节省不少系统资源了
function newlista($action){
$sql ="Select * from gx_news ";
if( $action=='today' ){ $sql.=" where datediff(new_time,".date("Y-m-d").")
$result =mysql_query($sql) or die('fail1'.mysql_error());
$rs =mysql_fetch_array($result);
$rdcount =mysql_num_rows($result);
if($rdcount){
$pagesize =15;
$pagecount=($rdcount % $pagesize)?(int)($rdcount / $pagesize)+1:$rdcount/$pagesize;//统计总页面
$page =isset($_GET['page'])?$_GET['page']:1;//取得当前页面
$start =($page>=1 && $page
$start =$start;
$sql =$sql." order by id desc limit $start,$pagesize";
$bg =1;
//$resulte =mysql_query($sql) or die('fail'.mysql_error());
$result =mysql_query($sql) or die(mysql_error());
while($rs =mysql_fetch_array($result) ){
if( $bg % 2 !=0){
$style="class=color";
}else{
$;
}
echo "
}
本人原创转载注明www.111cn.net/phper/php.html