php mySQL question.
How to get php to add/subtract a number (in the php code not an input) from a mySQL table by the press of a button?
Clicking a button (Sell) and it adds 50 to 9999.
Clicking a button (Buy) and it subtracts 50 from 10049.
That would be very useful in what I am building :)
Thanks in advance.
We need more information. Do you want a query? If you do try something like:
UPDATE table SET total = total + 50
More information on what you're trying to complete would be helpful. Also this isn't a very advanced topic so it probably should be moved.
I'm sorry... I thought of it as advanced.
Well... I want a php script to send total (9999) + 50 (All in a mySQL db e.g. SELECT Cash FROM `users` where username = '$username' )
and... well I'm not really a php person lolz so I think it would be a querry.
hope that cleared it up for ya
p.s. I already got a file that contains the mySQL login data. Its called database.php and it will be in the same directory as this file.
Maybe something like this...
$username = $_POST['username'];
$a = isset($_POST['a']) ? $a = $_POST['a'] : $a = $_GET['a'];
if($_POST['buy']) $value = -50;
if($_POST['sell']) $value = 50;
$sql = "
total = total + $value
username = '$username'
$result = mysql_query($sql) or die(mysql_error());