PDA

View Full Version : Help me with this query


mokujin
04-23-2010, 08:52 PM
hello,

I have this SQL
$buddys = $db->query_read("
SELECT user.username, user.userid
FROM " . TABLE_PREFIX . "userlist AS userlist
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid)
WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy'
");
Now how do I get all userid to one line like this: $buddyids = "1,9,67,89,102" ???

I want to use $buddyids to work with another query

Please help me

Thank you

--------------- Added 1272139718 at 1272139718 ---------------

No one can help me? Thank s

mokujin
04-25-2010, 11:28 AM
up. please help

Vaupell
04-25-2010, 01:34 PM
i would create an array or do a while loop instead using
something like


$currentid = $vbulletin->userinfo['userid'];
$myfriends = "";
$Buddylist=("SELECT * FROM ".TABLE_PREFIX." WHERE userid='".$currentid."'");
while($row=$vbulletin->db->fetch_array($Buddylist))
{
$myfriends .= $row['relationid'] .',';
}


and output would be of $myfriends something like

1,2,24,2,434,2, etc..

then i could always explode the contents if i needed them seperatly..
But you could also pull the individual user info of all the friends inside the loop,
after you got the $myfriends simple create another while loop inside
and fetch content from each user there, and store im in $myfriends[] array.