violinrocker Posted April 23, 2010 Share Posted April 23, 2010 $query = "SELECT * FROM friends WHERE username='$session->username'";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)) { //FIGURE OUT IF THE CURRENT FRIEND IS ONLINE $query2 = "SELECT * FROM active_users WHERE username='$row[friendname]'"; $result2 = mysql_query($query2) or die(mysql_error()); //IF THE CURRENT FRIEND IS ONLINE, SHOW CHAT LINK if($row2 = mysql_fetch_array($result2)) { echo "You have ".mysql_num_rows($result2)." friend/s online<br>"; }} i want to check the number of rows that are in 'active_users' problem is... when 2 rows are in 'active users' the statement "you have 1 friend/s online" also doubles.. and it doesnt add up... there are 2 but it is shown separately Link to comment https://forums.phpfreaks.com/topic/199486-mysql_num_rows/ Share on other sites More sharing options...
runnerjp Posted April 23, 2010 Share Posted April 23, 2010 $getusersonline = "SELECT * FROM active_users WHERE username='$row[friendname]'" ; //grab from sql users onLINE $getusersonline2 = mysql_query($getusersonline) or die("Could not get users"); $num = mysql_num_rows($getusersonline2); echo "<b>There " . ($num != 1 ? "are" : "is") . " $num user" . ($num != 1 ? "s" : "") . " currently ONLINE. </b>"; Link to comment https://forums.phpfreaks.com/topic/199486-mysql_num_rows/#findComment-1047004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.