php分页显示123456,分页功能123456

$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 "末页";

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?php include_once("function.php"); if($_POST[tj]) { $username=$_POST[username]; $identity=$_POST[user_number]; $phone=$_POST[user_tel]; $address=$_POST[address]; $carid=$_POST[car_number]; $cardescribe=$_POST[car_content]; $carluxian=$_POST[car_road]; car($username,$identity,$phone,$address,$carid,$cardescribe,$carluxian); echo "<script>alert('添加成功');</script>"; } if($_POST[update]) { $cid =$_POST[carid]; $username=$_POST[username]; $identity=$_POST[user_number]; $phone=$_POST[user_tel]; $address=$_POST[address]; $carid=$_POST[car_number]; $cardescribe=$_POST[car_content]; $carluxian=$_POST[car_road]; updatecar($username,$identity,$phone,$address,$carid,$cardescribe,$carluxian); echo "<script>alert('修改成功')</script>"; } if($_POST[delete]) { $cid=$_POST[car_number]; deletecar($cid); echo "<script>alert('删除成功')</script>"; } $result=selectcarid(); $yih=null; if($_POST[f]){ $cid1=$_POST[select1]; $yih=getCar($cid1); } ?> <html> <head><title>物流配送信息网</title> <script> function selectCar(){ document.getElementById('f').value="1"; document.forms[0].submit(); } function ck() { document.getElementById('cid').value="id"; } function bk() { document.getElementById('cid').value="pp"; } </script> </head> <body> <form method="POST"> <input type="hidden" name="f"> <table border="1" width="500px" height="20px"> <tr> <td align="center" colspan="2">车源信息管理: <select name="select1" onchange="selectCar()"> <option selected="selected">请选择</option> <?php while ($row=mysql_fetch_array($result,MYSQL_BOTH)) { ?> <option value="<?php echo $row[carid] ?>"><?php echo $row[carid] ?></option> <?php } ?> </select> </td> </tr> </table> <table width="685" border="1" cellpadding="1" cellspacing="1" bgcolor="#99FFCC"> <tr> <td width="80" height="26" align="center">姓名:</td> <td width="218"><input type="text" name="username" value="<?php echo $yih[username]?>" /></td> <td width="83" height="22" align="center">车牌号码:</td> <td width="281"><input name="car_number" type="text" value="<?php echo $yih[carid]?>" /></td> </tr> <tr> <td height="22" align="center">身份证号:</td> <td><input name="user_number" type="text" value="<?php echo $yih[identity]?>"/></td> <td rowspan="2" align="center">车辆描述:</td> <td rowspan="2" ><textarea name="car_content" cols="30" rows="5"><?php echo $yih[cardescribe]?></textarea></td> </tr> <tr> <td height="22" align="center">电话:</td> <td><input name="user_tel" type="text" value="<?php echo $yih[phone]?>"/></td> </tr> <tr> <td height="22" align="center">地址:</td> <td ><textarea name="address" id="address"><?php echo $yih[address]?></textarea></td> <td align="center">运输路线:</td> <td ><textarea name="car_road" cols="30" rows="5" id="car_road"><?php echo $yih[carluxian]?></textarea></td> </tr> <tr> <td> </td> <td align="right"><input type="submit" name="tj" value="提交" /></td> <td align="center"><input type="submit" name="update" value="修改" onclick="ck(<?php echo $yih[carid]?>)"></td> <td><input type="submit" name="delete" value="删除" onclick="bk(<?php echo $yih[carid]?>)"></td> </tr> </table> <input type="hidden" name="cid" value=""/> </form> </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值