Jump to content

online/offline bud


mc_keny

Recommended Posts

hey yallI manage to select the buds from the buddy list i have a section for online buds what i did was this$sql = mysql_query("SELECT mybud FROM mc_buddies WHERE iadd='".$uid."' And accept='0'"); while($item=mysql_fetch_array($sql)){//get bud from online list$item2 = mysql_fetch_array(mysql_query("Select nick,id FROM mc_online WHERE id='".$item[0]."'")); echo $item2[0];}it works perfectly it shows buds that are online now for off line i do this$sql = mysql_query("SELECT mybud FROM mc_buddies WHERE iadd='".$uid."' And accept='0'"); while($item=mysql_fetch_array($sql)){//get bud from off list$item3 = mysql_fetch_array(mysql_query("Select nick,id FROM mc_online WHERE id='".$item[0]."'"));if($item2[0]==0){ //select from users list instead t$item2 = mysql_fetch_array(mysql_query("Select nick,id FROM mc_users WHERE id='".$item[0]."'")); echo $item2[0];}}that works also it shows buds that are off line my prob now is i want to get the number of online buds and the off line buds

Link to comment
Share on other sites

By the way, you can optimise that script so you only have to do one query per group of users, e.g.

$sql = mysql_query("SELECT mybud, nick FROM mc_buddies, mc_online WHERE iadd='$uid' AND mc_online.id = mc_buddies.mybud AND accept='0'");while($item=mysql_fetch_array($sql)) {echo $item['nick'];}

Link to comment
Share on other sites

thanks bro it was a lot easier so am finish in showing online buds and the amount of online buds... i want to use that query for the offline buds i try adding a (!) not equal operation but it didn't work

Link to comment
Share on other sites

ok i got the table mc_buddies with these field id,iadd,mybud,acceptok when adding a bud i insert my id in 'iadd' and the person id into 'mybud' and accept='1' when they accept the request i update accept to accept='0' ok now in the buddy list i have $sql = mysql_query("SELECT mybud FROM mc_buddies WHERE iadd='".$uid."' AND accept='0'");while($item = mysql_fetch_array($sql)){echo $item[0];}it shows the users that i add but the users doesn't see me on there buddy list ???

Link to comment
Share on other sites

it shows the users that i add but the users doesn't see me on there buddy list
That's because the only record in the database says that they are your buddy, not that you are theirs. Either add a second record or check in the other field.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...