用PHP做批量删除数据 哪里,我个我有做过,用smarttemplate模板做的循环!也是生成checkbox,呵呵! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 偶也贴一个自己常用的~~function delRecord(){ var flag=true; var temp=""; var tmp; if((document.theForm.id_list.length+"")=="undefined") { tmp = 1 }else{ tmp = document.theForm.id_list.length } if (tmp==1){ if (document.theForm.id_list.checked) { flag=false; temp=document.theForm.id_list.value } }else{ for (i=0;i<document.theForm.id_list.length;i++) { if (document.theForm.id_list[i].checked) { if (temp=="") { flag=false; temp=document.theForm.id_list[i].value }else{ flag=false; temp = temp +","+ document.theForm.id_list[i].value } } } } if (flag) { alert("对不起,你还没有选择!"); }else{ if (confirm("删除后不可恢复,确定吗?")) { window.location="?action=del&id="+temp; return false; }else{ return false; } }return !flag;} html:message_list.html<table border=1 width="100%" cellspacing="0" cellpadding="1" bordercolordark=#EFEFEF bordercolor="#FFFFFF" style="font-size:12px;"> {section name=t loop=$message} {strip} <tr bgcolor="#FAFAFA" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFFFFF'"> <td width="5%" height="20" align="center" valign=middle style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><input type=checkbox name="chk[]" id="chkItem" value={$message[t].message_id}> </td> <td width="15%" align="left" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;">{$message[t].user_id}</td> <td width="45%" align="left" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><a href="./index.php?act=Message&CODE=00&message_id={$message[t].message_id}&sign=read" >{$message[t].sign1}{$message[t].title}{$message[t].sign2}</a></td> <td width="25%" align="left" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;" >{$message[t].record_date}</td> <td width="15%" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><a href="./index.php?act=Message&CODE=05&message_id={$message[t].message_id}" >回复</a></td></tr> {/strip} {/section}<p> <tr bordercolor="E5E5E5" bgcolor="#FFFFFF"> <td width="30%" height="22" align="left" colspan="2" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><a href="#" onmousemove ="window.status='';" onclick="check('1')">全选</a> -<a href="#" onmousemove ="window.status='';" onclick="check('0')">取消</a></td> <td width="70%" align="right" colspan="5" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;">{$Frist}{$Previous}{$Next}{$Last}{$Jump}</td> </tr></table><table width="100%" cellspacing="0" cellpadding="0" style="font-size:12px;"> <tr bordercolor="E5E5E5" bgcolor="E5E5E5"> <td width="60%" align="left" colspan="3"><input type="submit" value="删除"></td> <td width="40%" align="right" colspan="2">{$Total} 条信息中的 {$FR}-{$LA}</td> </tr></table>php:function message_delete() { global $gTPL,$gDB,$gINFO; $coun = count ($_POST['chk']); $tmp=$_POST['chk']; for ($i = 0; $i < $coun; $i++) { //删除操作 $query_str = "DELETE FROM message WHERE message_id =$tmp[$i]"; $gDB->query($query_str); } $this->message_list(); } 请教php处理html源代码方法!在线等 有时间的帮我一下忙撒。 不知道去哪儿寻求帮助来这里求个php论坛的URL规则 怎样实输入框的条件显示(有时候能输入有时候不能输入) 请问PHP可以调用MATLAB的m文件吗 PHP 抓取数据问题~!!大侠们进来啊~~~!! 内置函数别名 “18n_http_output“怎么用? 关于表格的问题 出现"不能连接服务器!"是什么意思,是不是没有数据库? csdn的帖子搜索只能针对标题么? 字符串连接符的问题 一些面试贴子,请各位帮忙看看。 怎么写最好!
{
var flag=true;
var temp="";
var tmp;
if((document.theForm.id_list.length+"")=="undefined")
{
tmp = 1
}else{
tmp = document.theForm.id_list.length
}
if (tmp==1){
if (document.theForm.id_list.checked)
{
flag=false;
temp=document.theForm.id_list.value
}
}else{
for (i=0;i<document.theForm.id_list.length;i++)
{
if (document.theForm.id_list[i].checked)
{
if (temp=="")
{
flag=false;
temp=document.theForm.id_list[i].value
}else{
flag=false;
temp = temp +","+ document.theForm.id_list[i].value
}
}
}
}
if (flag)
{
alert("对不起,你还没有选择!");
}else{
if (confirm("删除后不可恢复,确定吗?"))
{
window.location="?action=del&id="+temp;
return false;
}else{
return false;
}
}
return !flag;
}
<table border=1 width="100%" cellspacing="0" cellpadding="1" bordercolordark=#EFEFEF bordercolor="#FFFFFF" style="font-size:12px;">
{section name=t loop=$message} {strip}
<tr bgcolor="#FAFAFA" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFFFFF'">
<td width="5%" height="20" align="center" valign=middle style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><input type=checkbox name="chk[]" id="chkItem" value={$message[t].message_id}>
</td>
<td width="15%" align="left" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;">{$message[t].user_id}</td>
<td width="45%" align="left" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><a href="./index.php?act=Message&CODE=00&message_id={$message[t].message_id}&sign=read" >{$message[t].sign1}{$message[t].title}{$message[t].sign2}</a></td>
<td width="25%" align="left" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;" >{$message[t].record_date}</td>
<td width="15%" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><a href="./index.php?act=Message&CODE=05&message_id={$message[t].message_id}" >回复</a></td>
</tr>
{/strip} {/section}<p>
<tr bordercolor="E5E5E5" bgcolor="#FFFFFF">
<td width="30%" height="22" align="left" colspan="2" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;"><a href="#" onmousemove ="window.status='';" onclick="check('1')">全选</a> -<a href="#" onmousemove ="window.status='';" onclick="check('0')">取消</a></td>
<td width="70%" align="right" colspan="5" style="BORDER-LEFT-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-TOP-STYLE:none;border-bottom-color: #C0C0C0;">{$Frist}{$Previous}{$Next}{$Last}{$Jump}</td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0" style="font-size:12px;">
<tr bordercolor="E5E5E5" bgcolor="E5E5E5">
<td width="60%" align="left" colspan="3"><input type="submit" value="删除"></td>
<td width="40%" align="right" colspan="2">{$Total} 条信息中的 {$FR}-{$LA}</td>
</tr>
</table>
php:
function message_delete()
{
global $gTPL,$gDB,$gINFO;
$coun = count ($_POST['chk']);
$tmp=$_POST['chk'];
for ($i = 0; $i < $coun; $i++)
{
//删除操作
$query_str = "DELETE FROM message WHERE message_id =$tmp[$i]";
$gDB->query($query_str);
}
$this->message_list();
}