TEENFRONT Posted November 10, 2008 Share Posted November 10, 2008 Hey Im wanting to "ADD" something to a table row.. like, edit it... Usually, id use UPDATE users SET nickname='$nickname - $team' WHERE usermail='$useremail' But..in this case, it involves doing another query previous to the one above to get what $nickname is (i get $usermail from the submitted form, same as $team)... basically..i want to just add to the nickname field... So something like UPDATE users SET nickname=' - $team' WHERE usermail='$useremail' So its just adding the $team item to the nickname field... saving one query doesn't sound alot but i have over 270,000 users so saving every query where possible if crucial. So yeah, it there a way to append (i think thats the word lol) database values? Link to comment https://forums.phpfreaks.com/topic/132084-add-to-table-item/ Share on other sites More sharing options...
corbin Posted November 10, 2008 Share Posted November 10, 2008 Is team a column also? UPDATE users SET nickname = CONCAT_WS(' - ', `nickname`, `team`) <where clause>; Link to comment https://forums.phpfreaks.com/topic/132084-add-to-table-item/#findComment-686411 Share on other sites More sharing options...
TEENFRONT Posted November 10, 2008 Author Share Posted November 10, 2008 No $team is just text and is set elsewhere from a drop down... basically, you get to choose your team, then it adds the team name into your nickname which is then shown around the site, this is why im wanting to updating nickname and append team to it. i know i could have nickname and team in different columns and just echo $nickname - $team... but..i cannot change what is echoed i can just eacho $nickname , so this is why i need to add the team value to nickname.. lol weeeeeeeeeeee. Link to comment https://forums.phpfreaks.com/topic/132084-add-to-table-item/#findComment-686419 Share on other sites More sharing options...
trq Posted November 10, 2008 Share Posted November 10, 2008 So just use.... $sql = "UPDATE users SET nickname = CONCAT(nickname, '$team') WHERE usermail='$useremail'"; Link to comment https://forums.phpfreaks.com/topic/132084-add-to-table-item/#findComment-686422 Share on other sites More sharing options...
corbin Posted November 10, 2008 Share Posted November 10, 2008 "UPDATE table SET nickname = CONCAT_WS(' - ', `nickname`, '{$team}') WHERE <blah>" Bleh thorpe beat me. I open up like 20 tabs at a time, so I never know if someone has already replied. Posting it anyway. Link to comment https://forums.phpfreaks.com/topic/132084-add-to-table-item/#findComment-686425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.