thehigherentity Posted June 15, 2006 Share Posted June 15, 2006 is there a way to retreave all the data from a set user in a table?Im querying select username from users_table were userid = '$userid'then im using mysql_fetch_row($results);I believe this only brings the one row thoughand i want to bring more then one row back from the dbI have managed to do it,I called all the data from the table then looped through taking out what i wanted but I just wonderd if there was a better way?I have only been playing with mysql for a couple of days and realy have no idea what can and cant be done Quote Link to comment https://forums.phpfreaks.com/topic/12103-mysql-question-collecting-data-from-multiple-rows/ Share on other sites More sharing options...
d_barszczak Posted June 16, 2006 Share Posted June 16, 2006 [!--quoteo(post=384359:date=Jun 15 2006, 09:42 PM:name=thehigherentity)--][div class=\'quotetop\']QUOTE(thehigherentity @ Jun 15 2006, 09:42 PM) [snapback]384359[/snapback][/div][div class=\'quotemain\'][!--quotec--]is there a way to retreave all the data from a set user in a table?Im querying select username from users_table were userid = '$userid'then im using mysql_fetch_row($results);I believe this only brings the one row thoughand i want to bring more then one row back from the dbI have managed to do it,I called all the data from the table then looped through taking out what i wanted but I just wonderd if there was a better way?I have only been playing with mysql for a couple of days and realy have no idea what can and cant be done[/quote]This code will cycle through all of the results returned from the query then you do whatever you like with the results for example put them in an array or draw a HTML table.[code]while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) { extract($row); // Insert your code here}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12103-mysql-question-collecting-data-from-multiple-rows/#findComment-46193 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.