日期:2014-05-17  浏览次数:20539 次

这个delete删除 哪里错误了?
<table>
<tr>
  <td></td>
  <td><p style="font-size:13px;font-weight:bold;">Paper Title</p></td>
<td><p style="font-size:13px;font-weight:bold;">Comments</p></td>
<td><p style="font-size:13px;font-weight:bold;">Upload Date</p></td>
<td><p style="font-size:13px;font-weight:bold;">Delete</p></td>
</tr>
<?php
$con = @mysql_connect("localhost","root","")or die("failed to connect the database");
mysql_select_db("iccp",$con);
mysql_query("set names 'GBK'");
$sql="select * from t_paper where contributor_id=118";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
?>
<tr>
<td><input type="checkbox" name="name" value="<?=@$row['paper_title']?>"/></td>
<td><?=@$row['paper_title']?></td>
<td></td>
<td><?=@$row['upload_time']?></td>
<td><input name="submit" value="delete" type="submit"></td>
</tr>
</table>
<?php
}
if(!empty($_POST['name'])){
$str = explode(",",$_POST['name']);
  mysql_query("delete from t_paper where paper_title in($str)");}
?>


这里测试 为什么无法得到$_POST['name']的值

------解决方案--------------------
form 表单都没
<form method=post
------解决方案--------------------
另外,判断表单是否被提交应该用isset()
PHP code
if (isset($_POST['name'])) {
    $str = explode(",",$_POST['name']);
    mysql_query("delete from t_paper where paper_title in($str)"); //这里明显有问题,explode()函数返回的是一个数组,SQL语句语法错误了
}