好的家伙,这是一个更新,以便更准确地将脚本放在循环中
<?php....
while($row=mysql_fetch_row($result_set)){?>
......
<a href='#' id='<?php echo $row[0];?>'onClick="processDelete(this.id)">Delete</a>
以上是调用函数传递给javascript的代码
onclick会处理此ID,该ID指向标记ID,然后处理为脚本
接下来的代码是删除过程
<script>
function processDelete(id){
swal({
title:"delete",
text:"do you want to delete it?",
showCancelButton:True,
confirmButtonText:"Yes,Sir!",
cancelButtonText:"Nah still Need it",
closeOnConfirm: true
},
function()
{
window.location.href="delete.php?delete_id="+id;
}
})
}
</script>
所以也许下次我会用Codeigniter或Laravel 5发布它 评价和thnx阅读