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>";