我可以使用以下功能删除记录吗?如果是,我该怎么做?我必须将功能传递给提交按钮吗?
function deleteImage($id = "")
{
if(isset($_POST['delete_image']))
{
$query = mysql_query("DELETE FROM store WHERE id='$id'");
}
return $query;
}
html 看起来像这样:
<?php
$images = mysql_query("SELECT * FROM store");
while($row = mysql_fetch_assoc($images)) {
?>
<form action="admin.php" method="post">
<?php
echo "<img src=".$row['image'].">";
?>
<input type="submit" name="delete_image" value="DELETE IMAGE">
</form>
<?php
}
?>
提前致谢!