我想创建一个对话框,以便用户在要删除帖子时确认他的操作。我现在唯一遇到的问题是,如果我确认对话框,将删除具有下一个 ArticleID 的帖子,而不是我要删除的特定帖子。我做错了什么或者我必须添加什么来防止这个错误?
$result = $link->query('SELECT * FROM artikel ORDER BY artikelID DESC');
while($record = $result->fetch_array()){
echo '<div id="dialog-confirm" title="Delete post?">
</div>';
echo '<div class="artikel" style="clear: both;">
<a href="?actie=aanpassen&artikelID='.$record['artikelID'].'" id="aanpassenpost"><img src="icons/aanpassen.png" height="15" width="15"></a>
<img src="icons/delete.png" id="popup" height="15" width="15">
<script>
jQuery(function($) {
$("img#popup").click(function(event) {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:30,
modal: true,
buttons: {
"blabla": function(){
location.href = "?actie=verwijderen&artikelID='.$record['artikelID'].'";
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
});
</script>' ;
echo' <h3>'.$record['titel'].'</h3>
<p>'.$record['inhoud'].'</p>
</div>';
}
这是删除帖子的代码:
if(isset($_GET['actie']) && $_GET['actie'] == "verwijderen"){
$link->query('DELETE FROM artikel WHERE artikelID='.$_GET['artikelID'].';');