Infinity101
08-12-2012, 06:32 AM
Hello, I am in the process of writing a script which highlights buddy posts. I'm having trouble however passing a condition to only highlight the buddies and not everyone.
I have tried several conditionals, all either ending in showing no posts, or all posts. Below are variations of code I have used.
In myphp file:
When pulling information (used from misc.php):
$postbuddies = $db->query_read_slave("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.userid, session.lastactivity
FROM " . TABLE_PREFIX . "userlist AS userlist
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid)
LEFT JOIN " . TABLE_PREFIX . "session AS session ON(session.userid = user.userid)
WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy'
ORDER BY username ASC, session.lastactivity DESC
");
When Comparing
if(in_array(postbuddies['userid'], array(memberpost['userid'])){}
Pulling in separate instance (the above would be removed):
postbuddies = explode(' ', $buddies);
and in template:
<vb:if condition="is_array($memberpost[userid], array($postbuddies))"></vb:if>
I have tried several other variations similar to the above. I have ran a loops to make sure I was gathering the buddy userid which was successful. The problem seems to be when comparing with a poster's userid.
I hope my post makes sense, it's very late night for me and at this point I feel like my mind is going bonkers. Than you kindly for any help.
I have tried several conditionals, all either ending in showing no posts, or all posts. Below are variations of code I have used.
In myphp file:
When pulling information (used from misc.php):
$postbuddies = $db->query_read_slave("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.userid, session.lastactivity
FROM " . TABLE_PREFIX . "userlist AS userlist
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid)
LEFT JOIN " . TABLE_PREFIX . "session AS session ON(session.userid = user.userid)
WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy'
ORDER BY username ASC, session.lastactivity DESC
");
When Comparing
if(in_array(postbuddies['userid'], array(memberpost['userid'])){}
Pulling in separate instance (the above would be removed):
postbuddies = explode(' ', $buddies);
and in template:
<vb:if condition="is_array($memberpost[userid], array($postbuddies))"></vb:if>
I have tried several other variations similar to the above. I have ran a loops to make sure I was gathering the buddy userid which was successful. The problem seems to be when comparing with a poster's userid.
I hope my post makes sense, it's very late night for me and at this point I feel like my mind is going bonkers. Than you kindly for any help.