我正在尝试使用复选框删除 MySQL 日期行。当我应用下面的脚本时,它不会做我想做的事。没有执行动作..我得到了
Undefined variable: checkbox in C:\wamp\www\project\topics.php on line 108
我尝试回显正在发送执行的实际 sql,它给出了这个
DELETE FROM forum_topics WHERE topic_id = intval()
PHP
<?php
$topics = mysql_query(" SELECT topic_id , topic_head ,
topic_tags , topic_owner , topic_date
FROM forum_topics ") or die (mysql_error());?>
<form method='post' action='topics.php'>
<div class='admin'><table>
<tr>
<td >DELETE</td>
<td >ID</td>
<td>Title</td>
<td>Tags</td>
<td>Owner</td>
<td>Date</td>
</tr>
<?php
while($row=mysql_fetch_array($topics)){ ?>
<tr align=center>
<td align="center" bgcolor="black">
<input name="checkbox[]" type="checkbox" value="<?php echo $row['topic_id'];?>">
</td>
<td><?php echo intval($row['ID']); ?></td>
<td><?php echo htmlspecialchars($row['topic_head']); ?></td>
<td><?php echo htmlspecialchars($row['topic_tags']); ?></td>
<td>><?php echo htmlspecialchars($row['topic_owner']); ?></td>
<td>
<?php
$date = date_create($row['topic_date']) ;
echo date_format($date, 'F j, Y, g:i A');
?>
</td>
<?php echo"
</tr>";
}?>
<td ><input name="delete" type="submit" value="DELETE"></td>
<?php
// Check if delete button active, start this
if (isset($_POST['delete'])) {
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM forum_topics WHERE topic_id = intval($del_id)";
mysql_query($sql);
}
}
?>
</table>
</form>
</div>