Hey, I've got problem, I can't get it work as I want. I want a friendspage that shows the friends that you have added. And next to their names, I want it to show their onlinestatus, that means I have made some icons that I want to show up next to their names to show the status, if they are online, if they are offline etc.
Thanks, Huezzer
Friendscheck
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Friendscheck
Try looking at http://www.developphp.com and look under the PHP section...scroll to the bottom to the social network tutorial, he teaches how to do the add friends...
- Foofighter
- Posts: 121
- Joined: Sun Mar 04, 2012 1:52 pm
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: Friendscheck
Not sure what to add to help you, but if you cant make it work with the previous replies then try to make:
//inside the while loop that catches all your friends or whatever you are using
if($friend_online)
{
echo $name . " <img src='online.png'>";
}
else
{
echo $name . " <img src='offline.png'>";
}
not sure if that's what you are asking :S
//inside the while loop that catches all your friends or whatever you are using
if($friend_online)
{
echo $name . " <img src='online.png'>";
}
else
{
echo $name . " <img src='offline.png'>";
}
not sure if that's what you are asking :S
Re: Friendscheck
I agree with Spirit, definitely use that site as a starting point.
I have however produced a slightly cleaner method of retrieving the names of the users.
$query = "SELECT `user_id`, `username`, `username_clean` FROM `user_data` WHERE `user_id` IN ({$user->friends_list})";
If I remember rightly when he lists the names, he explodes the string and performs a query for every user id within the array. If you store your friends ids in a comma delimited list (which I believe is the way shown in those tutorials), the IN function will do the same thing in one query.
Just a small FYI for you and anyone who may need it
I have however produced a slightly cleaner method of retrieving the names of the users.
$query = "SELECT `user_id`, `username`, `username_clean` FROM `user_data` WHERE `user_id` IN ({$user->friends_list})";
If I remember rightly when he lists the names, he explodes the string and performs a query for every user id within the array. If you store your friends ids in a comma delimited list (which I believe is the way shown in those tutorials), the IN function will do the same thing in one query.
Just a small FYI for you and anyone who may need it
New Site Coming Soon! Stay tuned