Jump to content

mysql question, collecting data from multiple rows


thehigherentity

Recommended Posts

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 though

and i want to bring more then one row back from the db

I 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
[!--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 though

and i want to bring more then one row back from the db

I 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]

Archived

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

×
×
  • 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.