php为什么删除不了数据库中表内数据?
php:if(isset($_GET['deletejoke'])){try{$sql='DELETEFROMjokeWHEREid=:id';$s=$pdo->prep...
php:
if (isset($_GET['deletejoke']))
{
try
{
$sql='DELETE FROM joke WHERE id= :id';
$s = $pdo->prepare($sql);
$s->bindValue(':id', $_POST['id']);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error deleting joke: ' . $e->getMessage();
include 'error.html.php';
exit();
}
header('Location: .');
exit();
}
html:
<?php foreach ($jokes as $joke) :?>
<from action="?deletejoke" method="post">
<blockquote>
<p>
<?php echo htmlspecialchars($joke['text'], ENT_QUOTES,'UTF-8'); ?>
<input type="hidden" name="id" value="<?php echo $joke['id'];?>" >
<input type="submit" value="Delete" >
</p>
</blockquote>
</form>
<?php endforeach; ?>
点击删除按钮后没有任何反应 展开
if (isset($_GET['deletejoke']))
{
try
{
$sql='DELETE FROM joke WHERE id= :id';
$s = $pdo->prepare($sql);
$s->bindValue(':id', $_POST['id']);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error deleting joke: ' . $e->getMessage();
include 'error.html.php';
exit();
}
header('Location: .');
exit();
}
html:
<?php foreach ($jokes as $joke) :?>
<from action="?deletejoke" method="post">
<blockquote>
<p>
<?php echo htmlspecialchars($joke['text'], ENT_QUOTES,'UTF-8'); ?>
<input type="hidden" name="id" value="<?php echo $joke['id'];?>" >
<input type="submit" value="Delete" >
</p>
</blockquote>
</form>
<?php endforeach; ?>
点击删除按钮后没有任何反应 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询