当用户单击删除时,我需要制作一个 jQuery 来提醒“你确定要删除”。我一直在尝试很多但没有找到任何解决方案。
这是我的 deletemovie.php
<?php
require('../system/initialize.php'); //load the connection file
?>
<html><script src="../js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(".delete").click(function () {
if ( !confirm('Are you sure you want to delete?') ) {
return false;
} else {
$.ajax({
url: "deletemovie.php",
data: {movie_id},
type: 'get',
async: false,
success: function(result) {
if( result.success ) {
alert("You have successfully deleted");
}
}
})
}
})
)
</script>
</html>
<?php
$movie_id=$_GET['movie_id'];
$insert_user=mysql_query("DELETE FROM `movie` WHERE `movie_id` ={$movie_id}");
if($insert_user)
{ echo "DELETED";}
else
{ echo "error in registration".mysql_error(); }
?>
当然,在我的列表页面中,我做了:
echo "<a class='delete' href='deletemovie.php?movie_id={$movie_id}'>". delete .'</a><br/></td>';