Results 1 to 2 of 2
Thread: PHP Update Query in a forloop
Jun 30, 2007, 03:38 #1
- Join Date
- Jul 2006
- New Zealand
- 0 Post(s)
- 0 Thread(s)
PHP Update Query in a forloop
I have some problem with my code there is no errors with my code its for a game swelect list for user whos logged in to display wat games they like
what i have is a list menu which is called product
In my Actual PHP Code
if($product || $User)
//query to insert into cutomer
foreach($product as $prod)
$oQuery="update members set gamesplayed='".$prod."' WHERE username='".$_SESSION['user']."'";
echo "<br/><br/>Error Cannot Set Games Played Because ".mysqli_error($con);
update members set gamesplayed='Starcraft:Orginal' WHERE
update members set gamesplayed='Starcraft:Brood' WHERE username='Admin'
update members set gamesplayed='Diablo2' WHERE username='Admin'
update members set gamesplayed='Diablo2:Lod' WHERE username='Admin'
update members set gamesplayed='Warcraft' WHERE username='Admin'
When its meant to be game 1,game2,game3,game4 not when they select more than one
in the database for the field gamesplayed is varchar of 255
What am i doing wrong
can anyone help?
Jun 30, 2007, 04:19 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 49 Post(s)
- 1 Thread(s)
it appears as though you want the gamesplayed column to end up with a comma-delimited list of game names, right?
what you want isCode:
UPDATE members SET gamesplayed = CONCAT_WS(', ' , gamesplayed , 'Starcraft:Orginal' , 'Starcraft:Brood' , 'Diablo2' , 'Diablo2:Lod' , 'Warcraft' ) WHERE username = 'Admin'