<?php
session_start();
if ($sess_adminid<>session_id()) {
header ("Location:admin.php"); exit();
}
$id_order=$_GET[id_order];
include "Connections\connect.php";
$sql="SELECT*FROM tb_product,tb_order,tb_order_detail where id_prd=ref_id_prd and id_order=ref_id_order";
$result=mysql_db_query($dbname,$sql);
while ($rs=mysql_fetch_array($result)){
$id_prd=$rs[id_prd];
$ref_id_prd=$rs[ref_id_prd];
$number=$rs[number];
$quanlity_prd=$rs[quanlity_prd];
$re_q=$quanlity_prd-$number;
}
$sql="update tb_product set quanlity_prd='$re_q' where id_prd='$ref_id_prd'";
mysql_db_query($dbname,$sql);
$sql="delete from tb_order where id_order='$id_order' ";
mysql_db_query($dbname,$sql);
$sql="delete from tb_order_detail where ref_id_order='$id_order' ";
mysql_db_query($dbname,$sql);
echo"<H3>ลบ ใบสั่งซื้อสินค้าเรียบร้อยแล้ว</H3>";
echo"[<A HREF=admin_order.php>กลับหน้าหลัก</A>]";
mysql_close();
?>