Lamez Posted February 26, 2008 Share Posted February 26, 2008 I want to make a loop to run my script for all my users in the DB, but how? I have never made a loop, ever. Also when it pulls out the user will it be able to define it as $user? Link to comment https://forums.phpfreaks.com/topic/93033-loop-and-mysql/ Share on other sites More sharing options...
ratcateme Posted February 26, 2008 Share Posted February 26, 2008 $result=mysql_query('SELECT * FROM users'); while($row=mysql_fetch_array($result)){ //do something } Scott. Link to comment https://forums.phpfreaks.com/topic/93033-loop-and-mysql/#findComment-476617 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Author Share Posted February 26, 2008 how would I define $user? My code has $user in it to define where to pull info from the DB, and where to update it. Link to comment https://forums.phpfreaks.com/topic/93033-loop-and-mysql/#findComment-476622 Share on other sites More sharing options...
ratcateme Posted February 26, 2008 Share Posted February 26, 2008 i am assuming there is a row in your table called user or something similar make some code like this <?php $result=mysql_query('SELECT * FROM users'); while($row=mysql_fetch_array($result)){ $user=$row['user']; //code to use $user } ?> Scott. Link to comment https://forums.phpfreaks.com/topic/93033-loop-and-mysql/#findComment-476630 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Author Share Posted February 26, 2008 man I am retarded, that is is oblivious. Thank you Scott! Link to comment https://forums.phpfreaks.com/topic/93033-loop-and-mysql/#findComment-476635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.