PHP分页

#分页代码

<?php
header("content-type:text/html;charset=utf-8");
//连接数据库
$con = mysqli_connect("127.0.0.1","root","root","xzmh");
//print_r($con);die;
//选择数据库
//mysqli_select_db("xzmh");
//sql语句
$sql="select * from image ";

//执行
$moov=mysqli_query($con,$sql);
$num=mysqli_num_rows($moov);
//每页条数
$number=5;
//页数
$page_all=ceil($num/$number);
@$page=$_GET['page']?$_GET['page']:1;
if($page>$page_all){
  $page=$page_all;
}else if($page-1==0){
   $page=1;
}
$kk=($page-1)*$number;
$sqlt="select * from image limit $kk,$number";
//执行
$moovt=mysqli_query($con,$sqlt);


?>
<center>
<meta charset="utf-8"/>
<table border=1>
<tr><td><input type="checkbox" id="all" name="all" onclick="c_all()">全选/全不选</td>
	<td>id</td>
	<td>图片</td>
<!--
	<td>权限</td>
	<td>下载</td>
	<td><a href="loa.php">返回上传</a></td>   
-->
</tr>
<?php while($arr=mysqli_fetch_assoc($moovt)){ ?>
<tr>
	<td><input type="checkbox" name="c_all" value="<?php echo $arr['id']?>"></td>
	<td><?php echo $arr['id']?></td>

	<td><?php echo $arr['image']?>></td>
<!--
	<td><?php echo $arr['limits']?></td>
	<td><a href="down.php?path=<?php echo $arr['image']?>">下载</a></td>	
-->
 <?php } ?>
 <td></td>
</tr>
</table>
<input type="button" value="批量删除" onclick="fun()">
<a href="fff.php?page=1">首页</a>
<a href="fff.php?page=<?php echo $page-1?>">上一页</a>
<a href="fff.php?page=<?php echo $page+1?>">下一页</a>
<a href="fff.php?page=<?php echo $page_all?>">尾页</a>
</center>
<script type="text/javascript">
function fun(){
 al=document.getElementsByName("c_all")
str=""
 for(i=0;i<al.length;i++){
	 if(al[i].checked==true){
	str=str+","+al[i].value
	 }
	}
	kk=str.substr(1)
	
    if(confirm("确定要删除?")){
	  location.href="delete.php?id="+kk
	} else{
	    location.href="list.php"
	  }
}

 function c_all(){
    all=document.getElementById("all")
    al=document.getElementsByName("c_all")
    for(i=0;i<al.length;i++){
	 if(all.checked==true){
	  al[i].checked=true
	 }else{
	   al[i].checked=false
	  }
	}
 }

</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值