Jump to content

php query help


desithugg

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
Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.