unluckygirl
2010-01-04 05:48:30 UTC
I have queried the price from another database given it a variable name and then put it into my insert query. The update query works its just this insert into query please could you help?
my code is as follows:
$res = "SELECT *"."FROM love_cart,products "."WHERE love_cart.gst_id = '$sescart'&& products.cap = '$shwq'";
$reso = mysql_query($res) or die(mysql_error());
while($row = mysql_fetch_array($reso))
{
$chckp = $row['prod_name'];
$prce = $row['price'];
$lks = $row['size'];
}
if($q == $chckp && $lks = $qzqq )
$resup = mysql_query("UPDATE love_cart SET qty=qty+1,pricecrt=pricecrt+'$prce' WHERE gst_id='$sescart'&& prod_name='$shwq'&& size='$qzqq'")
or die(mysql_error());
else
mysql_query("INSERT INTO love_cart (gst_id,prod_name,pricecrt,qty,size) VALUES ('$sescart','$shwq','$prce','1','$qzqq')")
or die(mysql_error());
$req = "SELECT qty, SUM(qty) FROM love_cart WHERE gst_id='$sescart'";
$reqty = mysql_query($req) or die(mysql_error());
while($qre = mysql_fetch_array($reqty)) {
$qty = $qre['SUM(qty)'];
if($qty>0)
echo"My bag has $qty items $prce";
}
?>