desithugg Posted April 6, 2006 Share Posted April 6, 2006 lol back again needed a lil helpokay 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 exampleUsername ID status___________________________saad 1 admin alex 2 n00bKB 3 n00bdarkness 4 memberand 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 userive tried " AND 'darkness" " , 'darkness" " AND username = 'darkness' etcc..and lots of other stuff can som1 help me with this if its possiableand i need it so it can update unlimited amount of rows Quote Link to comment https://forums.phpfreaks.com/topic/6697-php-query-help/ Share on other sites More sharing options...
Javizy Posted April 6, 2006 Share Posted April 6, 2006 [!--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 helpokay 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 exampleUsername ID status___________________________saad 1 admin alex 2 n00bKB 3 n00bdarkness 4 memberand 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 userive tried " AND 'darkness" " , 'darkness" " AND username = 'darkness' etcc..and lots of other stuff can som1 help me with this if its possiableand 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 statusSET id = id + 1WHERE username IN ('saad', 'alex', 'KB' ); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/6697-php-query-help/#findComment-24360 Share on other sites More sharing options...
desithugg Posted April 6, 2006 Author Share Posted April 6, 2006 [!--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 statusSET id = id + 1WHERE username IN ('saad', 'alex', 'KB' ); [/code][/quote]umm lol looks like will work lol il try t later g2g to school thnx Quote Link to comment https://forums.phpfreaks.com/topic/6697-php-query-help/#findComment-24425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.