php分页程序及简单实例说明

$sql=select * from my_note where
note_url=’4′;$result=mysql_query($sql) or
die(‘Error’.mysql_error());$allrecord=mysql_num_rows($result);$page=isset($_GET[‘page’])?$_GET[‘page’]:1;$pagesize=10;$pagecount=($allrecord
% $pagesize)?(int)($allrecord / $pagesize) +1:$allrecord /
$pagesize;$page=($page$pagecount ||
$page1)?$page=1:$page;$start=$pagesize*($page-1);$sqllist=select *
from my_note where note_url=’4′ order by id desc limit
$start,$pagesize ;$resulte=mysql_query($sqllist) or die(‘Error
‘.mysql_error());$num=mysql_num_rows($resulte);if($num){while($rs=mysql_fetch_object($resulte)){if($rs-note_url==’1′){echo(liimg
src=’pic/point.jpg’ / a href=’.$rs-note_content.’ class=note
target=’_blank’.$rs-note_title./a [.$rs-note_date.] img
src=’pic/new.gif’ //lin);}else{echo(liimg src=’pic/point.jpg’ / a
href=’show.php?id=.$rs-id.’ class=note
target=’_blank’.$rs-note_title./a [.$rs-note_date.]/lin);}}echo(div
id=’page’div class=li 共.$pagecount.页 每页.$pagesize.条记录
共.$allrecord.个作品/div);for($i=$pagecount;$i=1;$i–){echo(div
class=lia href=?page=.$i..($i)./a/div);}echo(/div);}else{echo(‘No
Infomation’);}}

 

function newlista($action){
    $sql  =”Select * from gx_news  “;
    if( $action==’today’ ){ $sql.=” where
datediff(new_time,”.date(“Y-m-d”).”)<=0″; }
    $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卡塔尔(قطر‎?(intState of Qatar($rdcount /
$pagesize卡塔尔国+1:$rdcount/$pagesize;//总结总页面
    $page  =isset($_GET[‘page’])?$_GET[‘page’]:1;//取安妥前页面
    $start =($page>=1 &&
$page<=$pagecount)?$start=$pagesize*($page-1卡塔尔:$start=1;//得到超始记录
    $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{
    
      $style=””;
     
    }
    
    echo “<li $style><a
href=’newscenter.php?id=”.$rs[0].”‘ target=_blank
>”.$rs[‘new_title’].”</a><span>[“.$rs[‘new_time’].”]</span></li>
“;
    $bg++;
  }
   echo ‘</ul><div class=navigation>’;
   echo
“”.pagelist($page,$pagecount,$rdcount,’?page=’,$pagesize).”</div>”;
 }else{
   echo ‘一时半刻并未音讯!’;
 }

 }

自家原创转载声明www.111cn.net/phper/php.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注