عذراً على التأخير ..
انشغلت بفترة الامتحانات ..
هذا الكود لمن أراد الاستفاده
والشكر موصول للأخ محمد معاشر على مساعدته ..
$host = "localhost";
$username = "";
$password = "";
$db = "XXX";
$connect = mysql_connect($host,$username,$password) or die("Failed to Connect");
mysql_select_db($db) or die("Failed to Select $db");
$quantity = mysql_fetch_array(mysql_query("select * from product WHERE pdt_id = $pdt_id"),$connect);
$pdt_quantity=$quantity['pdt_quantity'];
$sql = "UPDATE product SET pdt_quantity = pdt_quantity - 1 WHERE pdt_id = '$pdt_id' ";
$sql1 = "INSERT INTO `order` (order_id,cust_user,pdt_id,date) VALUES ('$order_id','$cust_user' ,$pdt_id,'$date')";
$sql2 = "UPDATE product SET pdt_status = 'not available' WHERE pdt_id = '$pdt_id' ";
///////////////////////////////////////////////////////////////////////////////////////
if ($pdt_quantity > 1 ) {
mysql_query($sql) or die("Could not update the quantity");
mysql_query($sql1) or die("Could not insert into order");
echo" <font color=#800000>Thank you for buying from us
<br>
<font color=#800000>to view what did you buy</font> <a class=footer_link target=_self href=cust_mydesk.php><font color=#FF0000>click here ";
}
////////////////////////////////////////////////////////////////////////////////////////
elseif ($pdt_quantity == 1 ) {
mysql_query($sql) or die("Could not update the quantity");
mysql_query($sql1) or die("Could not insert into order");
mysql_query($sql2) or die("Could not change the quantity status");
echo" <font color=#800000>Thank you for buying from us
<br>
<font color=#800000>to view what did you buy</font> <a class=footer_link target=_self href=cust_mydesk.php><font color=#FF0000>click here</a></font> ";
}
////////////////////////////////////////////////////////////////////////////////////////
else {
echo" <font color=#800000>you cannot buy this product ,not exist ";
}نسأل الله النفع والفائدة للجميع
تم تعديل هذه المشاركة بواسطة سعيد محمد في 9 يوليو 2008 في 22:13
