mc_keny Posted February 17, 2008 Share Posted February 17, 2008 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 More sharing options...
Synook Posted February 17, 2008 Share Posted February 17, 2008 mysql_num_rows() Link to comment Share on other sites More sharing options...
Synook Posted February 17, 2008 Share Posted February 17, 2008 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 More sharing options...
mc_keny Posted February 17, 2008 Author Share Posted February 17, 2008 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 More sharing options...
Synook Posted February 17, 2008 Share Posted February 17, 2008 Can you show us what you now have? Link to comment Share on other sites More sharing options...
mc_keny Posted February 18, 2008 Author Share Posted February 18, 2008 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 More sharing options...
mc_keny Posted February 18, 2008 Author Share Posted February 18, 2008 any help pls Link to comment Share on other sites More sharing options...
justsomeguy Posted February 18, 2008 Share Posted February 18, 2008 it shows the users that i add but the users doesn't see me on there buddy listThat'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 More sharing options...
mc_keny Posted February 19, 2008 Author Share Posted February 19, 2008 yeah i figure that much bro if i do this WHERE mybud='".$uid."' it shows the person me thats two different query but i only want one query and put it in a while loop Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2008 Share Posted February 19, 2008 That's what OR is for. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.