ddm Posted March 13, 2006 Share Posted March 13, 2006 Hi All, I am a php newbie, I am trying to create a site where users will register and enter their yahoo id. I want the users who are online on their yahoo messengers to show first on the list of users.Here is the code that will show if they are online or offline on yahoo.[code]<?php // Request Profile Info $result = @mysql_query("SELECT * FROMprofile"); if (!$result) { echo("<p>Error performing query: " . mysql_error() ."</p>"); exit(); } // Display the Content of the profile Table while ( $row = mysql_fetch_array($result) ) {$PrimaryYID = $row['PrimaryYID'];echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"3\" width=\"400\">"; $url = "http://mail.opi.yahoo.com/online?u=".$PrimaryYID."&m=t&t=0"; $handle = fopen ("$url", "r"); $contents = ""; do { $data = fread($handle, 10000); if (strlen($data) == 0) { break; } $contents .= $data; } while(true); fclose ($handle); if ((strpos(strtoupper($contents),"NOT ONLINE") ? strpos(strtoupper($contents),"NOT ONLINE")+1 : 0)>0) { $imgStatus = "<img src='ym/offline.gif' ALT='OFFLINE' border='0'>"; } else { $imgStatus = "<img src='ym/online.gif' ALT='ONLINE' border='0'>";} echo "<tr bgcolor=\"#eeeeee\"><td><b><a href=\"ymsgr:sendIM?$PrimaryYID\">$PrimaryYID</a></b></td><td align=\"center\"><a href=\"ymsgr:sendIM?$PrimaryYID\"> $imgStatus </a></td></tr>";}echo "</table>";?>[/code]I dont know how I can make it that those who are online on their yahoo messenger to show first on the list. Please help me.Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/4828-yahoo-online-status/ Share on other sites More sharing options...
justsomeone Posted March 14, 2006 Share Posted March 14, 2006 [!--quoteo(post=354491:date=Mar 13 2006, 02:13 PM:name=ddmluvdlm)--][div class=\'quotetop\']QUOTE(ddmluvdlm @ Mar 13 2006, 02:13 PM) [snapback]354491[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi All, I am a php newbie, I am trying to create a site where users will register and enter their yahoo id. I want the users who are online on their yahoo messengers to show first on the list of users.[/quote]Your database has no idea if people are logged into yahoo or not. So your while loop which processes the database results can't be changed to sort by Yahoo logged in status.What you need to do is to use the while loop to populate a new array which stores the database row, a 1 or a 0 to indicate Yahoo Logged in status and maybe their username as well.You can then sort this array by logged in status, and username.Finally you can walk through this array to print out the results. This would allow you to show all the logged in users first (listing them alphabetically), then all the other users (again alphabetically).J Quote Link to comment https://forums.phpfreaks.com/topic/4828-yahoo-online-status/#findComment-17308 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.