Jump to content

Yahoo Online Status


ddm

Recommended Posts

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 * FROM
profile");
  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.

Link to comment
Share on other sites

[!--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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.