I have no idea how to do addition or subtraction in a mysql database using php. Basically I am looking to have a text box that someone would input the amount of an item they want to purchase, and then it would multiply the amount they want by the cost, and it would do 2 things:
1. add the amount of bait to the persons inventory
2. subtract the sum of the numbers multiplied from their money
would anyone be able to assist me with this.
The variables I am using in this document are:
I figured out how to get it to work with a set amount like below:
$sql = "update birds_sighting set bait_amount = bait_amount + 1 where user = '1'"; $result = mysql_query ($sql);
$sql = "update birds_sighting set money = money - 200 where user = '1'"; $result = mysql_query ($sql);
I just need to figure out how to make it have text boxes that will multiply the 2 values together
also, i am having issues when selling, the items will still sell even when the value goes to a negative number. would anyone be able to help me figure out how to make it stop before it reaches 0 so i do not get a negative number?
Last edited by omegaxero; 11-18-09 at 23:00.
Reason: found 1 solution, need the other still