Count users who added me to their buddylist
walker2238 - October 6, 2008 - 23:00
| Project: | Buddylist |
| Version: | 5.x-1.1-beta |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I've been looking around the forums and found code to display a count of buddies a user has added to their buddylist...
<?php
$result = "SELECT DISTINCT(u.uid) as buddy, u.access FROM {buddylist} b INNER JOIN {users} u ON b.uid = u.uid WHERE b.buddy = %d ORDER BY u.access DESC";
print '<p class="column">Total number of fans: ' . $result->buddy . '</p>';
?>My problem is how can I change this to display the total number of users who have added me to their buddylist? Instead of showing who I added to my buddylist.
Thanks in advance for any help...

#1
Please ignore the above code as that is my lame attempt at getting it to show people who added me to their buddylist without even using COUNT haha dumb.... the code I am using to show who I added is as follows
<?php$result = db_fetch_object(db_query('SELECT COUNT(*) AS how_many FROM {buddylist} WHERE uid = %d', $user->uid));
print '<p class="column">Total number of favorites: ' . $result->how_many . '</p>';
?>
Sorry...
#2
Well I figured it out. So if anyone else is looking for this here is how you show the number of users who added you to their buddylist... to be displayed in the users profile... Nice module BTW very well documented.
<?php
$result = db_fetch_object(db_query('SELECT COUNT(*) AS how_many FROM {buddylist} b INNER JOIN {users} u ON b.uid = u.uid WHERE b.buddy = %d', $user->uid));
print '<p class="column">Total number of users who have added you to their buddylist: ' . $result->how_many . '</p>';
?>