Jump to content

Archived

This topic is now archived and is closed to further replies.

desithugg

php query help

Recommended Posts

lol back again needed a lil help
okay i succefully got the data from the multiple select option form to insert but not i need to know how to updat two or more rows at the same time for example

Username ID status
___________________________
saad 1 admin
alex 2 n00b
KB 3 n00b
darkness 4 member


and i want to update the 'id' colum for user both saad and darkness

<?php
$result = mysql_query("UPDATE status SET id= id + 1 WHERE username='saad'")
or die(mysql_error());
?>

but this would only update for 1 user
ive tried " AND 'darkness"
" , 'darkness"
" AND username = 'darkness' etcc..
and lots of other stuff can som1 help me with this if its possiable

and i need it so it can update unlimited amount of rows

Share this post


Link to post
Share on other sites
[!--quoteo(post=362093:date=Apr 6 2006, 01:52 AM:name=desithugg)--][div class=\'quotetop\']QUOTE(desithugg @ Apr 6 2006, 01:52 AM) [snapback]362093[/snapback][/div][div class=\'quotemain\'][!--quotec--]
lol back again needed a lil help
okay i succefully got the data from the multiple select option form to insert but not i need to know how to updat two or more rows at the same time for example

Username ID status
___________________________
saad 1 admin
alex 2 n00b
KB 3 n00b
darkness 4 member
and i want to update the 'id' colum for user both saad and darkness

<?php
$result = mysql_query("UPDATE status SET id= id + 1 WHERE username='saad'")
or die(mysql_error());
?>

but this would only update for 1 user
ive tried " AND 'darkness"
" , 'darkness"
" AND username = 'darkness' etcc..
and lots of other stuff can som1 help me with this if its possiable

and i need it so it can update unlimited amount of rows
[/quote]

You would use OR instead of AND, or a shortened version IN (as I was told earlier).

[code]UPDATE status
SET id = id + 1
WHERE username IN ('saad', 'alex', 'KB' ); [/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=362124:date=Apr 5 2006, 11:05 PM:name=Javizy)--][div class=\'quotetop\']QUOTE(Javizy @ Apr 5 2006, 11:05 PM) [snapback]362124[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You would use OR instead of AND, or a shortened version IN (as I was told earlier).

[code]UPDATE status
SET id = id + 1
WHERE username IN ('saad', 'alex', 'KB' ); [/code]
[/quote]


umm lol looks like will work lol il try t later g2g to school thnx

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.