I cant figure it out. I have this variable (for example):
$level_building = "test,";
and this sql string:
mysql_query("UPDATE info_buildings SET building='$level_building' + building WHERE nick='$nick'") or die(mysql_error());
all i want to do is to add new text test,
after existing text, but after updating it, sql shows 0 (building=0
).. My sql output should look like this test,test,test,
... Example: building=test,test,test,
and each time i use sql string UPDATE
it should write new test
text in the same building
string.. Sorry for bad english i hope you understand this.
In MySQL, +
is for arithmetic addition. To concatenate strings, use CONCAT()
:
UPDATE info_buildings
SET building = CONCAT('$level_building', building)
WHERE nick = '$nick'
All the MySQL string functions can be found here.
However, I recommend you reconsider your table design. Putting comma-separated lists in a single column is usually poor design. You should use a separate table with a row for each value.