I have got a problem.
Here is my script
$connect = mysqli_connect("mysql.cba.pl","piotr_luszcz","password","leggendinho");
$result = mysql_query("SELECT * FROM moneytable WHERE name LIKE '$_POST[post_name]'");
if(mysql_num_rows($result) == 0) {
mysqli_query($connect,"INSERT INTO moneytable (name, money) VALUES ('$_POST[post_name]', '$_POST[post_money]')");
} else {
$sql = "UPDATE moneytable SET money = money + '$_POST[post_money]'" ;
}
Here is my problem:
I need to do a html page where im putting name and money that person needs to give me back. Adding person name and money is ok into mysql, but I can't upgrade column money if name in database exists, its just making a new column.
I don't know if I've written "column" correctly, I mean the data you put into database
An UPDATE query should have WHERE condition, otherwise it will affect all the rows in your table.Change your UPDATE query like below:
$sql = "UPDATE moneytable SET money = money + '".$_POST[post_money]."' WHERE name ='".$_POST['name']."'" ;