$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 $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) $next = $offset + 20 ;
$last=($page-1)*20;
echo "下页 ";
echo "末页";
}
?>