Kingy Posted February 25, 2008 Share Posted February 25, 2008 ok this is hard to explain so i'll try to do it best i can... when a user connects to irc my php bot will update the mysql database and set online to 1, likewise when someone disconnects the bot will set online to 0. Ok simple i have got that sorted.... But occasionally the bot will ping out and the when it finally reconnects some people have left, others have joined etc etc leaving there database online row all wrong. What i'm trying to do is return the names list.. I can do this by going //NAMES # and it'll return the names on a single line User1 User2 User3 heres my code so far.... <?php $opsreplace = array(":", "+", "%", "@", "&", "~"); // replacing irc op symbols $users = str_replace($opsreplace, "", $names[5]); $userlist = split(" ", $users); // splits the single line (users) into an array $syncselect = mysql_query("SELECT * FROM usersonline WHERE online='1'") or die(mysql_error()); while($userow = mysql_fetch_array($syncselect)) { foreach($userlist as $user) { $dbuser = $userow['username']; if("$dbuser" == "$user") { echo "Online: $dbuser"; } else { echo "Offline: $dbuser"; } } } // want it to go through the users online and tell me which are still on the irc and which arn't anymore ?> This code so far works pretty good, it will tell me who is still online but when it comes to telling me who is offline, again it does tell me, but it also repeats itself a fair amount.. Heres an example NB: USER 1 is on the IRC USER 2 is not USER 3 is on the IRC Offline: User1 Offline: User1 Online: User1 Offline: User1 Offline: User2 Offline: User2 Offline: User2 Offline: User2 Offline: User3 Online: User3 Offline: User3 Offline: User3 Quote Link to comment Share on other sites More sharing options...
trq Posted February 25, 2008 Share Posted February 25, 2008 SELECT DISTINCT * FROM usersonline WHERE online='1' Quote Link to comment Share on other sites More sharing options...
Kingy Posted February 25, 2008 Author Share Posted February 25, 2008 nope i still get the same repeating over and over again.. i think the reason why its repeat is because if useronline = user1 user1 online user2 offline user3 offline if useronline = user2 user2 online user1 offline user3 offline so if one user is online then the other 2 users are offline Quote Link to comment Share on other sites More sharing options...
Kingy Posted February 26, 2008 Author Share Posted February 26, 2008 anyone have any ideas on how to stop this happening.. if i don't put an else statement its all good and will only show the users online, but i need it to show the users who are offline so i can update the mysql databases Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.