Jump to content


Photo

Problems with code to change value


  • Please log in to reply
2 replies to this topic

#1 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 17 April 2006 - 09:43 PM

Hi,
My form outputs the quantity and productID correctly on the form but i can't seem to decrease the amount for quantity by the quantity output.

while($row1 = mysql_fetch_array($result1))
{
echo "<td><b>";
echo ''.$row1['quantity'].'';
echo "</b></td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
echo "<td><b>";
echo ''.$row1['stockID'].'';
$sql = REPLACE INTO Stock (stockAmt) VALUES (" stockAmt - ''.$row1['quantity'].'' ")
WHERE stockID = " ''.$row1['stockID'].'' ";
mysql_query($sql);

}

The problem is the code in bold. I don't get where i am going wrong as the correct values are ouput but when i use the bit to replace the value, it causes a blank output so there is an error somewhere. If you know what it is please let me know.
Thanks.

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 17 April 2006 - 11:50 PM

Try this one:

$sql = 'REPLACE INTO Stock (stockAmt) VALUES (" stockAmt - ' . $row1['quantity']. ' ") WHERE stockID = "' . $row1['stockID']. ' " ';

~ D Kuang

#3 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 18 April 2006 - 12:03 AM

Tried it, still a blank page.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users