พี่ช่วยแนะนำการลบid ทั้ง2 ที่มีความสัมพันธ์กันหน่อยครับ ต้องใส่ไว้ในส่วนไหนครับ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา พี่ช่วยแนะนำการลบid ทั้ง2 ที่มีความสัมพันธ์กันหน่อยครับ ต้องใส่ไว้ในส่วนไหนครับ
พี่ช่วยแนะนำการลบid ทั้ง2 ที่มีความสัมพันธ์กันหน่อยครับ ต้องใส่ไว้ในส่วนไหนครับ
Copy
ต้องการลบ id_pro ครับ ในตารางorders และในตาราง product
<?
ob_start();
session_start();
if($_SESSION["user_adm"]=="")
{
header('location:index.php');
exit();
}
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
require_once('../connect.php');
//=========== ถ้ามีการลบรายการสินค้า
if($_GET["Action"]=="Delete")
{
//=========== ลบตาราง cusorder หมายเลขใบสั่งซื้อ
$sql_del= "delete from orders where id_ord='".$_GET["id_ord"]."'";
$dbquery_del = mysql_query($sql_del);
//=========== ลบรายละเอียดว่าได้สั่งซื้อะไรบ้าง
echo"<script language='JavaScript'>";
echo"alert('ลบข้อมูลเรียบร้อยแล้ว');";
echo"window.location='cusorder.php';";
echo"</script>";
}
?><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.::รายการสั่งซื้อทั้งหมด::.</title>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>
<div align="center"><br>
<table cellspacing=0 cellpadding=4 width="75%" bgcolor=#CCCCCC border=1 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="100%" bgcolor="#FFFFFF"> <div align="center"></div>
<table cellspacing=1 cellpadding=4 width="100%" border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="35%" bgcolor="#FFFFFF"> <div align="left"><b><img src="../image/allrowto.gif" width="11" height="11" align="absbottom">
</b> <strong>รายการสั่งซื้อทั้งหมด</strong></div></td>
<td width="22%" align=middle bgcolor="#FFFFFF"> <div align="left">
</div></td>
<td width="43%" bgcolor="#FFFFFF"> <div align="right"><a href="menuadmin.php">กลับไปหน้าหลัก</a></div></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div>
<table width="68%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="58%"> </td>
<td width="42%"> </td>
</tr>
</table>
<table cellspacing=1 cellpadding=3 width="75%" bgcolor=#CCCCCC border=0 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td bgcolor="#FFFFFF"><div align="center">รหัสสั่งซื้อ</div></td>
<td bgcolor="#FFFFFF">ชื่อ</td>
<td bgcolor="#FFFFFF"><div align="center">สถานะ</div></td>
<td bgcolor="#FFFFFF"><div align="center">วันที่</div></td>
<td bgcolor="#FFFFFF"><div align="center">ลบ</div></td>
</tr>
<?
$i=0;
//=========== นำข้อมูลมาแสดงทั้งหมด
$sql = "select * From orders";
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =10;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
$sql .= " Where 1 order by id_ord desc LIMIT $Page_start , $Per_Page"; //////////////////////////////// โค้ดเเบ่งหน้า
//ส่วนแสดงผล
$strSQL = ("SELECT * FROM (orders LEFT JOIN customer ON orders.id_cust = customer.id_cust) ORDER BY id_ord");
$objQuery = mysql_query($strSQL) or die(mysql_error());
while ($record=mysql_fetch_array($objQuery)) {
?>
<tr bgcolor=#e5e5e5>
<td width="132" bgcolor="#FFFFFF"><div align="center"><a href="orderdetail.php?id_ord=<?=$record["id_ord"];?>">
<?=$record["id_ord"];?>
</a></div></td>
<td width="198" bgcolor="#FFFFFF">
<?=$record["name_cust"];?>
<?=$record["sur_cust"];?>
</a></td>
<td width="183" bgcolor="#FFFFFF">
<div align="center">
<?
if($record["status_cust"]=="1")
{
echo "รอการชำระเงิน";
}
else
{
echo "ชำระเงิน/จัดส่งสินค้าไปแล้ว";
}
?>
</div></td>
<td width="150" bgcolor="#FFFFFF"> <div align="center">
<?=$record["day_ord"];?>
</div></td>
<script language="JavaScript">
function Conf<?=$i; ?>(object) {
if (confirm("ยืนยันการลบ [ <?=$record["id_ord"]; ?> ] ") ==true) {
return true;
}
return false;
}
</script>
<td width="46" bgcolor="#FFFFFF"><div align="center"><a href="<?=$_SERVER['PHP_SELF'];?>?Action=Delete&id_ord=<?=$record["id_ord"];?>" onClick="return Conf<?=$i; ?>(this)"><img src="../image/delete.gif" width="12" height="11" border="0"></a></div></td>
</tr>
<?
}
?>
</tbody>
</table>
<br>
<br>
<table width="75%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> จำนวน
<?= $Num_Rows;?></b>
แบ่งเป็น : <b>
<?=$Num_Pages;?>
</b> ไปยัง :
<?/* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page'><< Back </a> ";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo " [ <a href='$PHP_SELF?Page=$i'>$i</a> ]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo " <a href ='$PHP_SELF?Page=$Next_Page'> Next >> </a>";
?></font>
</td>
</tr>
</table>
</body>
</html>
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ