Politically correct has the proper solution! Just add a field in your users table called "online" and set it true when user logs-in, and false when he logs-off!
But if you can't change your table:
Use "join" (http://www. sitepoint.com / understanding-sql-joins -mysql-database/) ( remove spaces)
=> select * from `online_users` join `users` where xxx would be the way, but I do not know your table format.
Personnally, I NEVER use "join": it is a source of horrible optimisation problems and source of bugs, and it means that my tables are badly designed!!! :-)
I would do:
ASSUMING you have a field in users_online AND users called "userid"...
$link = dbconnect(); // your function to connect
$sql1 = "select `userid` from `online_users` where 1"; // to select all users that are on-line.
$res1 = mysqli_query($link, $sql1); // the list of online users
while ($row1 = mysql_fetch_array($res1))
{
$sql2 = "select * from `users` where `userid`='".$row['userid']."'";
$res2 = mysqli_query($link, $sql2);
$row2 = mysqli_fetch_array($res2); // you should only have ONE entry, so, no "while"
mysqli_free_result($row2);
// now you have userid from online_users, = to userid in `users` + details of that user: organise your output...
}
mysqli_free_result($res1);
...