Hi i have a DB Entry that only consists of a number. and i want to Make it where users on my site can Exchange from One to the Other and i know how to do all that but i dont wanna Replace the current value i just wanna add for example 1,000 to it what code can i use in PHP ?
First, you must specify the name of the table. After that, in parenthesis, you must specify the column name of the table, and columns must be separated by a comma. The values that you want to insert must be inside the parenthesis, and it must be followed by the VALUES clause.
To prepend a string to a column value in MySQL, we can use the function CONCAT. The CONCAT function can be used with UPDATE statement.
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("UPDATE `some_table` SET `value` = `value` + 1000 WHERE `id` = 1");
mysql_close($con);
?>
update like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With