ปุ่ม Delete ไม่ลบข้อมูลที่เลือก
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา ปุ่ม Delete ไม่ลบข้อมูลที่เลือก
ปุ่ม Delete ไม่ลบข้อมูลที่เลือก
Copy
คลิกปุ่ม Delete แล้วขึ้น alert ว่า Delete Succesfuly แต่ข้อมูลไม่ลบ เป็นเพราะอะไรคะ
------------ Delete.php ------------------
<meta charset=utf-8" />
<?php include('connection.php'); //ไฟล์เชื่อมต่อกับ database ที่เราได้สร้างไว้ก่อนหน้าน้ี
//สร้างตัวแปรเก็บค่าที่รับมาจากฟอร์ม
$groupID = $_GET['groupID'];
//ลบข้อมูลออกจาก database ตาม groupID ที่ส่งมา
$sql = "DELETE FROM user_group, permission_module
USING user_group
INNER JOIN permission_module
WHERE user_group.groupID ='$groupID'
AND permission_module.groupID = user_group.groupID"
or die("Error:" . mysqli_error($conn));
$result = mysqli_query($conn, $sql) or die ("Error in query: $sql " . mysqli_error());
//จาวาสคริปแสดงข้อความเมื่อบันทึกเสร็จและกระโดดกลับไปหน้าฟอร์ม
if($result){
echo "<script type='text/javascript'>";
echo "alert('Delete Succesfuly');";
echo "window.location = '3.php'; ";
echo "</script>";
}
else{
echo "<script type='text/javascript'>";
echo "alert('Error back to delete again');";
echo "</script>";
}
?>
--------------------------- Delete Modal -----------------------
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title" id="deleteModalLabel"><b>ยืนยันการลบข้อมูล</b></h6>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
คุณต้องการลบกลุ่มผู้ใช้นี้หรือไม่</div>
<div class="modal-footer">
<form class="form-horizontal" role="form" method="post" action="Delete.php?groupID=$row[0]" enctype="multipart/form-data">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Close</button>
<button class="btn btn-primary" type="submit">Delete</button>
</form>
</div>
</div>
</div>
</div>
------------------ ปุ่ม opn modal delect -----------------------------
<button class="btn btn-datatable btn-icon btn-transparent-dark" type="button" data-toggle="modal" data-target="#deleteModal">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2">
<polyline points="3 6 5 6 21 6"></polyline>
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
<line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line>
</svg>
</button>
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ