Page 1 of 1
sort mysql results after query... need expert advice
Posted: Thu Feb 11, 2010 12:41 pm
by scarface222
removed
Re: sort mysql results after query... need expert advice
Posted: Thu Feb 11, 2010 1:28 pm
by social_experiment
What information will be displayed with the second query? If there is an id of the user inside the first query, you could possibly use that to tie the two queries together?
Re: sort mysql results after query... need expert advice
Posted: Thu Feb 11, 2010 1:34 pm
by scarface222
Thanks for the response man
well each table does have an id called topic_id for each topic.
information would look like this in while statement
Code: Select all
$topic_id=$row['topic_id'];
$creator=$row['creator'];
$description=$row['description'];
$topic_title=$row['topic_title'];
I thought about tying them like that, I just was not sure how to since the full first query must be executed to get the number of users. The second query just says topic title, usernumber (from first query function), who created the topic etc. I just wanted to sort the results by usernumber determined by first query but wasn't sure how since they queries are of two separate tables.
Re: sort mysql results after query... need expert advice
Posted: Fri Feb 12, 2010 1:19 am
by social_experiment
Since you are selecting everything from the table, you could use a mysql_fetch_array() to get the value $value['topic_id']. Once you have that, you could do a join between the two tables, but if the second table has all the information you need displayed, then a join with the first table wont be neccessary. If however you do need something from the first table a join might look something like this :
Code: Select all
<?php $sql = "SELECT * FROM to JOIN scrusersonline ON to.topic_id = scrusersonline.topic_id ORDER BY scrusersonline.usernumber ASC"; ?>
Re: sort mysql results after query... need expert advice
Posted: Fri Feb 12, 2010 9:45 am
by scarface222
removed, I am a dumbass lmao. I do not want to say what the problem was. I was just extremely careless.