2012-07-28, 02:44 AM
I would like to show users' avatars on the online users list on the forum index, and I found this tutorial - http://yaldaram.com/showthread.php?tid=3784
That works great, but that's only for showing it on the actual online.php page and doesn't work on the forum index. I had a play around and decided to add the following code;
...to my index.php file directly above these lines;
It works kind of, but it only shows one user instead of all of the ones that are online.
I don't know what bit to edit to make it show all online users. Can anyone help me? Thanks
I've fixed it. I changed the beginning of the code to;
...and now it works
That works great, but that's only for showing it on the actual online.php page and doesn't work on the forum index. I had a play around and decided to add the following code;
$query = $db->simple_select("users", "*", "uid='{$user['uid']}'");
$us = $db->fetch_array($query);
if ($us['avatar'] != "")
{
$user_avatar = '<img src="'.$us['avatar'].'" alt="Avatar" title="'.$user['username'].' \'s Avatar" width="35px" height="35px">';
}
else
{
$user_avatar = '<img src="images/default_avatar.gif" alt="Avatar" title="'.$user['username'].' \'s Avatar" width="35px" height="35px">';
}
...to my index.php file directly above these lines;
// Properly format the username and assign the template.
$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
It works kind of, but it only shows one user instead of all of the ones that are online.
I don't know what bit to edit to make it show all online users. Can anyone help me? Thanks
I've fixed it. I changed the beginning of the code to;
$query2 = $db->simple_select("users", "*", "uid='{$user['uid']}'");
$us = $db->fetch_array($query2);
...and now it works