Chinaunix首页 | 论坛 | 博客
  • 博客访问: 874447
  • 博文数量: 245
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 2801
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-15 10:31
文章分类

全部博文(245)

文章存档

2011年(1)

2010年(43)

2009年(102)

2008年(99)

我的朋友

分类: WINDOWS

2008-11-05 13:08:25

if($offset==""){ $offset=0;}
include"conn.php";
$sql1 = "select * from writeMessage order by id desc limit $offset ,20";
$query1 = mysql_query($sql1);
$sql2="select count(*) from writeMessage";
$query2=mysql_query($sql2);
$result1=mysql_fetch_array($query2);
$total=$result1[0];
$page=ceil($total/20);
$now = $offset/20 + 1;
while($result=mysql_fetch_array($query1)){
echo $result['content']."
".$result['time']."

";
?>
苫布
}
?>


 if($offset != 0 ){
 $pre = $offset - 20 ;
 echo "首页  ";
 echo "上页";
 }
 ?>
 
  if($page<=6){//The total page's number is less than 6 pages or equal to 6 pages ;
    for($i=0;$i<$page;$i++){//Complate the cirle of the pages
      $j=$i+1;
      $k=$i*20;
      if($k==$offset){
        echo "".$j."  ";
      }else{
        echo "(".$j.")  ";
      }
   }
    }//The end of  cirle
 if($page>6){// When the total page's number are more than 6 pages
     if($now<=3){//The current page number is less than the number 3 or equal to the number 3
         for($i=0;$i<6;$i++){
           $j = $i + 1;
           $k = $i*20;
     if($k==$offset){
             echo "".$j."  ";
           }else{
          echo "(".$j.")  ";
              }
      }
   }// the end of the cirle when the current page  number is less than 3
         
   
     elseif($now>3&&$now+3<=$page){
     //when the current page number is larger than 3 and the current page plush 3 is small than the total page's number
           for($i=$now-3;$i<=$now+3;$i++){
       $k = ($i-1)*20;
        if($k==$offset){
                 echo "".$i."  ";
              }else{
            echo "(".$i.")  ";
        }
               }
       }
    elseif($now+3>$page){
          for($i=$page-5;$i<=$page;$i++){
         $j=($i-1)*20;
        if($j==$offset){
                 echo "".$i."  ";
              }else{
           echo "(".$i.")  ";
        }
       }
       }
      }
 ?>
    if(($now*20)<$total){
 $next = $offset + 20 ;
 $last=($page-1)*20;
 echo "下页  ";
  echo "末页";
  }
  ?>
阅读(801) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~