把你每条记录的ID也列出来,用复选框去决定要删除哪条ID!
解决方案 »
- 关于BBS 版主授权的问题
- 求教,关于Rewrite中的路径问题。
- yzx.frm是存在的可是系统报Table 'dz.yzx' doesn't exist错误
- 一个剩法计算乱码问题。
- 哪里可以获得 PHP 官方的 MD5 函数的源代码?
- 关于PHP计划任务ignore_user_abort的问题
- 关于PHP+SyBase数据库的程序运行环境配置问题(setcookie不能用),
- 一个程序,我调试了1个多小时还没结果!大家帮我找找毛病!!
- php session问题
- html5中 FormData api ajax使用的问题
- 请问谁知道在php中获得客户机的操作系统,浏览器值的函数是什么啊?
- 急需 :列表框List控件多选时提交,如何取得所有选中的值
测试 PHP 2002-08-05 26 12 checkbox复选框
$row[1]="测试" $row[2]="php" $row[3]="2002-08-05".....$row[x]=id
<input type=checkbox name=del_id value="<?php edho $row[id];?>">
$query="del from $table_name where id="del_id"";
$result=mysql_query($query);
统计选中的总数,放入一个循环即可.
的确可以删除文章,不过一次只能删除一个id所对应的文章
如果一次通过checkbox复选框选择多个id,也只能删除id最小的文章
请问我该如何处理???
我写的代码如下:
--------delete_word1.php---------<form method="POST" action="delete_word2.php">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="40%" align="center">文章名称</td>
<td width="15%" align="center">文章类型</td>
<td width="15%" align="center">上传时间</td>
<td width="15%" align="center">阅读次数</td>
<td width="15%" align="center">删除选择</td>
</tr>
<?php
if($offset=="")
{
$offset=0;
}
$connid=mysql_connect("localhost","","");
$sql="select id,title,type,time,number from word order by id";
$result=mysql_db_query("supersite",$sql);$fsql="select id from word";
$fresult=mysql_db_query("supersite",$fsql);
$num=mysql_num_rows($fresult);if ($num != 0)
{
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$ftitle=$r["title"];
$ftype=$r["type"];
$ftime=$r["time"];
$ftime=substr($ftime,0,10);
$fnumber=$r["number"];
echo "<tr><td width='/40%'/>";
echo "<a href=update_word2.php?id=$id>";
echo $ftitle;
echo "</a></td><td width=/'15%'/>";
echo $ftype;
echo "</td><td width=/'15%'/>";
echo $ftime;
echo "</td><td width=/'15%'/>";
echo $fnumber;
echo "</td><td width=/'15%'/>";
echo "<input type=checkbox name=del_id value=$id>";
echo "</td></tr>";
}
}
?>
</table><input type="submit" value="提交" name="B1" style="float: right"><input type="reset" value="重置" name="B2" style="float: right"></form>--------delete_word2.php---------<?php
echo $del_id;
$connid=mysql_connect("localhost","","");
$query="delete from word where id='$del_id'";
if (mysql_db_query("supersite",$query));
{
echo "文章删除完毕!";
}
?>
<?php//name:list.php
// bye eagle_gui -- >http://www.ggajj.net
// 2002-08-06
print"<form name=artical action=del.php method=post>";print"<table width=100% border=1>";
print"<tr>
<td>文章名称</td><td>文章类型</td><td>上传时间</td><td> 阅读次数</td><td> 删除选择 </td></tr>";
for ($i=0;$i<$total;$i++)
{
print"<tr><TD>$title</td> <TD>$type</td><TD>$date</td><TD>$clicks</td><TD><input type=checkbox naem=delartical[] value=$id></td>}
print"<tr><td><input type=submit value=删除></td></tr></table>";
print"</form>";?>
del.php
<?php//-----name:del.php
// By eagle_gui :http://www.ggajj.net
// 2002-08-06$total=sizeof($delartical);
for ($i=0;$i<$total;$i++)
{
$connid=mysql_connect("localhost","","");
$query="delete from word where id='$delartical[$i]'";
$res=mysql_query($query,$connid) or die ("无法删除");
}
print"<P align=center><BR><BR><BR>成功删除,请<a href=list.php>返回</a></p>";
?>