[56K WARN] stock after customer add item to cart
Posted: Wed May 17, 2006 3:33 pm
i am a super newbie to php,i can make the cart untill this step it is bcos of the help of schoolmate!the problem might be easy for u guys here,but it is tough for me!i am super dumb in programing world!but i really need help for this php code,thank u everyone who helps me!!
i put the pictures and code,mayb can let ppl understd more easily!!thank you very much!!!!

my problem is: how to code after a customer has added the items to the cart,the value of the stock
decrease.
this is the code in 'movies.php' page.
this is the code in 'cart.php' page.
pls dun laught at my question!!! ^^
i put the pictures and code,mayb can let ppl understd more easily!!thank you very much!!!!

my problem is: how to code after a customer has added the items to the cart,the value of the stock
decrease.
this is the code in 'movies.php' page.
Code: Select all
<?php
if($_POST['add'])
{
$movieID=$_POST["movieID"];
$num=$_POST["num"];
$_SESSION["cart"][$movieID] += $num;
echo "added ok!!"; echo "<br>";
}
if($_POST["delete"])
{
$_SESSION["cart"]=array();
echo "delete your cart ok!!"; echo "<br>";
}
?>Code: Select all
foreach($_SESSION["cart"] as $movieID=>$num)
{
$sql="select * from movies where MovieID=".$movieID;
//print $sql;
$rs=mysql_query($sql,$myConn);
$row=mysql_fetch_array($rs);
$ss=$num*$row["Price"];
echo "<tr>";
echo "<td>";
print $row[1];
echo "</td>";
echo "<td>";
print $row[2];
echo "</td>";
echo "<td>";
print "<img src='images/".$row["3"]."' height=50 width=50>";
echo "</td>";
//print $movieID;
print "<td>";
print $num;
print "</td>";
echo "<td>";
print $ss;
echo "</td>";
$sum+=$ss;
echo "</tr>";
}
echo "<tr>";
echo "<td colspan=4>";
print "Total Sum is ";
echo "</td>";
echo "<td>";
echo $sum;
echo "</td>";
echo "</tr>";
echo "</table>";