21,887
社区成员
发帖
与我相关
我的任务
分享
echo "<center>" ;
echo "<form action ='../huwai/sou.php?action=del' method='POST' onSubmit='return confirm(\'你确定要删除这些纪录吗?\')'>" ;
echo "<table cellspacing='0' cellpadding='2' border='1' bordercolor='#66FF66' width='1400px'>" ;
echo "<tr bgcolor='#FFFFCC' align='center' height='20px'>" ;
echo "<th width='50px'><strong>ID号</strong></th>" ;
echo "<th><strong>日期</strong></th>" ;
echo "<th width='50px'><strong>编号</strong></th>" ;
echo "<th width='50px'><strong>县区</strong></th>" ;
echo "<th width='400px'><strong>具体地址</strong></th>" ;
echo "<th width='50px'><strong>科室</strong></th>" ;
echo "<th width='50px'><strong>姓名</strong></th>" ;
echo "<th width='60px'><strong>联系电话</strong></th>" ;
echo "<th width='30px'><strong>油</strong></th>" ;
echo "<th width='30px'><strong>米</strong></th>" ;
echo "<th width='30px'><strong>围裙</strong></th>" ;
echo "<th width='30px'><strong>现金</strong></th>" ;
echo "<th width='50px'><strong>皮革抽纸盒</strong></th>" ;
echo "<th width='50px'><strong>水宜生杯子</strong></th>" ;
echo "<th width='50px'><strong>三件套水杯</strong></th>" ;
echo "<th width='30px'><strong>高</strong></th>" ;
echo "<th width='30px'><strong>长</strong></th>" ;
echo "<th width='30px'><strong>面积</strong></th>" ;
echo "<th width='30px'><strong>安装结果</strong></th>" ;
echo "<th width='300px'><strong>备注</strong></th>" ;
echo "<th width='20px'><strong>结账状态</strong></th>" ;
echo "<th colspan='3' align='center'></th>" ;
echo "</tr>" ;
$num=8;
$sql1="select * from place {$where}";
$result1=mysql_query($sql1);
$total=mysql_num_rows($result1);
$page=new Page($total,$num,$args);
$sql="select id,time,number,xianqu,address,keshi,name,tel,you,mi,weiqun,money,pgczh,beizi,sjtsb,high,width,area,azjg,bz,jzzt from place {$where} order by `id` DESC {$page->limit}";
$result=mysql_query($sql);
while(list($id,$time,$number,$xianqu,$address,$keshi,$name,$tel,$you,$mi,$weiqun,$money,$pgczh,$beizi,$sjtsb,$high,$width,$area,$azjg,$bz,$jzzt)=mysql_fetch_row($result)){
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$time</td>";
echo "<td class='number'>$number</td>";
echo "<td>$xianqu</td>";
echo "<td>$address</td>";
echo "<td>$keshi</td>";
echo "<td>$name</td>";
echo "<td>$tel</td>";
echo "<td>$you</td>";
echo "<td>$mi</td>";
echo "<td>$weiqun</td>";
echo "<td>$money</td>";
echo "<td>$pgczh</td>";
echo "<td>$beizi</td>";
echo "<td>$sjtsb</td>";
echo "<td>$high</td>";
echo "<td>$width</td>";
echo "<td>$area</td>";
echo "<td>$azjg</td>";
echo "<td>$bz</td>";
echo "<td>$jzzt</td>";
echo "<td><a href='../huwai/huwaimod.php?action=mod&id=$id'>修改</a></td>";
echo "<td><a href='../huwai/sou.php?action=del&id=$id' onclick='return confirm('确定要删除?')'>删除</a></td>";
echo "<td><input type='checkbox' name='id[ ]' value ='$id' ></td>";
echo "</tr>";
$totalarea += $area;
}
echo "<tr><td colspan='21' align='center'><span class='fenye'><ul class='fr'> {$page->fpage(array(1,8,2,3,4,5,6,7,0))}</ul></span></td><td colspan='3' align='center'><input type='submit' name='dosubmit' value='删除'/></td></tr>";
echo "<tr><td colspan='24' align='center'>总面积<本页合计>: ".$totalarea." 平方米(按搜索条件计算)</td></tr>";
echo "</table>";
echo "</form>";
echo "</center>";
$sqlarea = "select sum(area) as totalarea from place {$where}";
$resultarea = mysql_query($sqlarea);
//先把mysql结果数组化,再取值
$rowarea = mysql_fetch_array($resultarea);
我在QQ群里问了,有人给我正确的答案了,就是要先把query结果数组化,然后再取值才行,要不然就会提示resource id #6
下列代码就是提取数组中的值啦!
echo "<tr><td colspan='21' align='center'><span class='fenye'><ul class='fr'> {$page->fpage(array(1,8,2,3,4,5,6,7,0))}</ul></span></td><td colspan='3' align='center'><input type='submit' name='dosubmit' value='删除'/></td></tr>";
echo "<tr><td colspan='24' align='center'>面积<本页合计>: ".$totalarea." 平方米 总面积<搜索总计>: ".$rowarea['totalarea']." 平方米 注:按搜索条件计算</td></tr>";
$sql1="select * from place {$where}";
$result1=mysql_query($sql1);
$total=mysql_num_rows($result1);
改为$sql1 = "select count(*), sum(area) from place {$where}";
$result1 = mysql_query($sql1);
list($total, $allarea) = mysql_fetch_row($result1);
$allarea 就是总面积
//如果keshi不为空,说明想搜索科室
if(!empty($tmp['keshi'])){
$whr[]="keshi like '%{$tmp['keshi']}%'";
}
//如果address不为空,说明想搜索地址
if(!empty($tmp['address'])){
$whr[]="address like '%{$tmp['address']}%'";
}
//如果number不为空,说明想搜索画面编号
if(!empty($tmp['number'])){
$whr[]="number like '%{$tmp['number']}%'";
}
//如果azjg不为空,说明想搜索安装结果
if(!empty($tmp['azjg'])){
$whr[]="azjg like '%{$tmp['azjg']}%'";
}
//如果jzzt不为空,说明想搜索结账状态
if(!empty($tmp['jzzt'])){
$whr[]="jzzt like '%{$tmp['jzzt']}%'";
}
//如果jzzt不为空,说明想搜索结账状态
if(!empty($tmp['bz'])){
$whr[]="bz like '%{$tmp['bz']}%'";
}
//如果$whr数组不为空,说明有搜索条件,用and把$whr数组组合在一起
if(!empty($whr)){
$where = " where " .implode(" and ",$whr);
$args = http_build_query($tmp);
}
else{
$where=" ";
}
//删除数据代码
if(isset($_GET['action'])){
//删除纪录的动作
if($_GET['action'] == "del"){
//删除多个
if(!empty($_POST['id'])){
$sql = "delete from place where id in (".implode(',',$_POST['id']).") ";}
//删除单个
else {
$sql = "delete from place where id = '{$_GET['id']}'";
}
$result = mysql_query($sql);
if($result && mysql_affected_rows() > 0){
$page="../huwai/sou.php";
//设置修改成功后返回前一页,并刷新
echo "<script>alert('删除成功');window.location = \"".$page."\";</script>";
}
else{
echo "删除失败!<br>";
}
}
}