index.php
<body style="font-size:12px;">
<script type="text/javascript" language="javascript">
function selectBox(selectType){
var checkboxis = document.getElementsByName("Checkbox");
if(selectType == "reverse"){
for (var i=0; i<checkboxis.length; i++){
//alert(checkboxis[i].checked);
//checkboxis[i].checked = !checkboxis[i].checked;
checkboxis[i].checked = false;
}
}
else if(selectType == "all")
{
//alert(document.getElementsByName("Checkbox").length);
for (var i=0; i<checkboxis.length; i++){
//alert(checkboxis[i].checked);
checkboxis[i].checked = true;
}
}
}
function deleteSelect(){
var aryId = [];
var checkboxis = document.getElementsByName("Checkbox");
for (var i=0; i<checkboxis.length; i++){
//alert(checkboxis[i].checked);
if(checkboxis[i].checked)
aryId.push(checkboxis[i].value);
}
if(aryId.length > 0)
{
if(confirm("该操作比较危险请慎重 确实要删除吗"))
location.href = "deleteit.php?action=deleteQuestion&aryId=" + aryId.join(",");
else
for (var i=0; i<checkboxis.length; i++){
//alert(checkboxis[i].checked);
//checkboxis[i].checked = !checkboxis[i].checked;
checkboxis[i].checked = false;
}
}
else
{
alert("请选择要删除的记录!");
}
}
</script>
<?php
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("Asia/Shanghai");
$cn=mysql_connect("localhost","root","1*****u");
$db=mysql_select_db("dedecms");
$masterTb="dede_archives";
$smallTb="dede_addonarticle";
$feedbackTb="dede_feedback";
$id=$_REQUEST["id"];
//显示文章评论/
echo "文章评论如下:"."<br/>";
$query="select * from ".$feedbackTb;
$result=mysql_query($query);
$num=mysql_num_rows($result);
$pageSize=10; //每页显示的记录数
if(isset($_GET['page'])) //获取当前页数
{
$page=intval($_GET['page']);
}
else
{
$page=1;
}
if($num)
{
if($num<$pageSize)
{
$pageNum=1; //只有一页
}
if($num % $pageSize)
{
$pageNum=(int)($num/$pageSize)+1;
}
else
{
$pageNum=$num/$pageSize;
}
}
else
{
$pageNum=0;
}
$pageString = ''
if( $page == 1 ){
$pageString .= '第一页|上一页|'
}
else{
$pageString .= "<a href=".""index.php?page=1"."">首 页</a>|<a href=".""index.php?page=".($page-1)."">上一页</a>|";
}
if( ($page == $pageNum) || ($pageNum == 0) ){
$pageString .= "下一页|尾页";
}
else{
$pageString .= "<a href=".""index.php?page=".($page+1)."">下一页</a>|<a href=".""index.php?page=".$pageNum."">尾页</a>";
}
$fristNum=($page-1)*$pageSize;
$query1="select * from ".$feedbackTb." limit $fristNum, $pageSize ";
mysql_query("SET NAMES utf8");
$res=mysql_query($query1);
if($num!=0){
?>
<table border=1 align=center width=80%>
<?php
while($row=mysql_fetch_array($res))
{
echo "<Tr><Td>";
echo "<input type=checkbox id=Checkbox name=Checkbox value=".$row["id"].">";
echo $row["id"];
echo $row["username"]."于".date("Y-m-d H:i:s",$row["dtime"])."写道";
echo " "."<font color="red">".$row["msg"]."</font> ";
echo "</td></tr>";
}
echo "<p align="center">";
echo "<tr><td>";
?>
<input id="Button3" type="button" value="全选" onclick="selectBox('all')" />
<input id="Button1" type="button" value="反选" onclick="selectBox('reverse')" />
<input id="Button2" type="button" value="删除所选" onclick="deleteSelect()" />
<?php
echo $pageString;
echo " 共".$pageNum."页|当前第".$page."页".",共有".$num."条记录";
echo "</td></tr>";
echo "</table>";
}
else{
echo " 暂无评论";
}
?>
</body>
deleteit.php
<?php
$arr=$_REQUEST["aryId"];
$a=split(",",$arr);
for($i=0;$i<count($a);$i++){
//echo $a[$i];
$sql="delete from dede_feedback where id=".$a[$i];
$cn=mysql_connect("localhost","root","1*****u");
$db=mysql_select_db("dedecms");
mysql_query("set names utf8");
mysql_query($sql);
header("location:index.php");
}
/*
$listid=explode(",",$_REQUEST["aryId"]);
for($i=0;$i<count($listid);$i++){
$sql="delete from info where id=".$listid[$i];
echo $sql."<br>";
}
*/
?>