user198989 user198989 - 4 years ago 111
PHP Question

MySQL add data to row after existing data

I am trying to add new data right after the current data. This works well,

mysql_query("UPDATE uyeler SET shoots=shoots + 1 WHERE nick='admin'")

However, its only for numbers. I tried that with normal text value

$places = "london";
mysql_query("UPDATE uyeler SET shootplaces= shootplaces + '".$places."' WHERE nick='admin'")

But all it does is that it makes the shootplaces to 0. What is the correct way to add new value to a row without deleting the current value in it ?

Answer Source

You have to use Mysql CONCAT function.

$places = "london";
mysql_query("UPDATE uyeler SET shootplaces= CONCAT(shootplaces , '".$places."') WHERE nick='admin'")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download