页面:内容显示.php
<td width="100"><a onclick="return confirmSubmit()" href="delete.php?id=<?php echo $row['id']; ?>&table=labour_details&return=content_display.php"><img src="../images/delete.png" border="0" alt="delete"></a></td>
页:删除.php
if(isset($_GET['id']) && isset($_GET['table']))
{
$id=$_GET['id'];
$tablename=$_GET['table'];
$return=$_GET['return'];
if($tablename=="labour_details")
{
$sql=mysql_query("SELECT * FROM `labour_details` WHERE `id`='$id'");
$row_1=mysql_fetch_array($sql);
$labour_name= $row_1['labour_name'];
if($labour_name!="")
{
$str=mysql_query("DELETE FROM `labour_details` WHERE `id`='$id'");
if($str)
{
header("location:$return?msg=Record Deleted Successfully!&id=$id");
}else{
echo "Problem in deleting :";
}
}
}
}
我的问题是在哪里添加警报,以便在删除记录之前显示 javascript 消息,如果允许,它将删除记录。
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to Delete this Entry?");
if (agree)
return true ;
else
return false ;
}