这是我获取的数据。
<table id="dt-opt" class="table table-lg table-hover">
<thead>
<tr>
<th>Customer Name</th>
<th>Contact</th>
<th>Email</th>
<th>City Name</th>
<th>Area Name</th>
<th>Address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$counter = 0;
$sel_query = mysql_query("SELECT * FROM customer_details, city_mst, area_mst WHERE customer_details.CITY_ID = city_mst.CITY_ID AND customer_details.AREA_ID = area_mst.AREA_ID");
while($sel = mysql_fetch_array($sel_query))
{
?>
<tr>
<td><?php echo $sel['CUSTOMER_NAME']?></td>
<td><?php echo $sel['CONTACT_NO']?></td>
<td><?php echo $sel['EMAIL']?></td>
<td><?php echo $sel['CITY_NAME']?></td>
<td><?php echo $sel['AREA_NAME']?></td>
<td><?php echo $sel['ADDRESS']?></td>
<td><a href="cust_save.php?delid=<?php echo $sel['CUSTOMER_ID']?>" class="btn btn-sm btn-danger"><i class="fa fa-trash"></i></a></td>
</tr>
<?php
}
?>
</tbody>
这是我的删除页面:cust_save.php
if(isset($_GET['delid']))
{
include "script/db.php";
$pid = $_GET['delid'];
echo $query = "DELETE FROM customer_details WHERE CUSTOMER_ID = $pid";
if(mysql_query($query))
{
header("Location:cust_view.php?msg=Deleted");
}
else
{
header("Location:cust_view.php?msg=Failed");
}
}
当我点击删除按钮时它显示甜蜜的警报我实际上不明白如何实现请帮助我。
我正在使用核心 php 代码,我正处于学习阶段,所以如果有人知道这个答案,请帮助完成我的作业。
最佳答案
获取 sweet alert 的库,调用它,然后在你删除时执行此操作
<?php
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("Your Title","Your message","error");';
echo '}, 1000);</script>';
?>
关于php - 如何在 php 中删除时使用 sweetalert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48691960/