Jump to content


Photo

mysql question, collecting data from multiple rows


  • Please log in to reply
1 reply to this topic

#1 thehigherentity

thehigherentity
  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 15 June 2006 - 08:42 PM

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
The best way to learn
is to ask you lot........

#2 d_barszczak

d_barszczak
  • Members
  • PipPipPip
  • Advanced Member
  • 188 posts
  • LocationBradford - UK

Posted 16 June 2006 - 08:01 AM

[!--quoteo(post=384359:date=Jun 15 2006, 09:42 PM:name=thehigherentity)--][div class=\'quotetop\']QUOTE(thehigherentity @ Jun 15 2006, 09:42 PM) View Post[/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.

while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) {
     extract($row);

     // Insert your code here
}

When all else fails - Try reading the manual.

Integrated IT Systems Ltd





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users