#分页代码
<?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>