mysql query...need expert advice
Posted: Thu Feb 11, 2010 7:28 pm
Ok let me try to word my last problem in a simpler manner.
this function determines the number of active users viewing each topic
This query displays the topic and its information, notice the function from the first query is used to display the number of users viewing each page in the while statement
I want to delete the field 'user_number' used in the second query and somehow order the information instead by the variable $userscount determined by the external query since it displays the same information. Is this in anyway possible? (to order mysql query by external information?) PS both tables share the field topic_id.
this function determines the number of active users viewing each topic
Code: Select all
function usersCount1($pgcod,$topic_id)
{
$qryuserscount="SELECT * FROM scrusersonline WHERE usersonlineusrip!='1' AND id!='0' AND topic_id='$topic_id'";
$userscount=mysql_query($qryuserscount);
$count = mysql_num_rows($userscount);
return("$count");
}Code: Select all
$sql="SELECT * FROM topic ORDER BY user_number DESC LIMIT $start, $limit";
while($row = mysql_fetch_array($result))
{
echo usersOnline(1,$topic_id);
}