【发布时间】:2017-06-24 17:40:01
【问题描述】:
我有这个代码,我正在做一个下拉菜单,让人们选择他们想要删除的通知,但我不知道我的代码有什么问题......我是新人......很抱歉因为我的无知
PHP代码:
<?php
include('configdb.php')
if(isset($_POST['delete']))
{
$query_delete = "DELETE from artigos where idartigos >0";
$resultado_delete = mysqli_query($mysqli,$query_delete) or
die(mysqli_error($mysqli));
if($resultado_delete)
{
echo "
<script language='JavaScript'>
window.alert('Notícia eliminada com sucesso. Clique para voltar à página inicial.')
window.location.href='index.php';
</script>";
}
else
{
echo "
<script language='JavaScript'>
window.alert('Não foi possível apagar a sua notícia. Tente novamente, sff. Clique para voltar à página inicial.')
window.location.href='index.php';
</script>";
}
}
?>
HTML 代码:
<h1>Apagar notícia</h1>
<a>Notícias disponíveis</a><br><br>
<select name="delete" style="width:332px">
<?php echo $artigos; ?>
</select><br><br>
<p>eliminar
<input type="submit" name="submit" id="submit" action= "delete.php" value="delete" />
</p>
【问题讨论】:
-
您必须在 html 代码中修复表单 w3schools.com/html/html_forms.asp
-
好吧...表格在哪里?至少你需要指定方法。 @NareshTeli 她正在使用新版本。
-
我为您提供链接。您只需阅读即可,如何在 html 中编写表单;
-
@NareshTeli 老兄,认真的吗?你明白我刚才告诉你的吗?哈哈。那是新的。
标签: php html mysql dropdown delete-row