Jump to content

[SOLVED] Strange Problem: Missing Database Info


Styles2304

Recommended Posts

Strange problem . . . I have 7 entries in the database. The way it's supposed to work is that the person viewing their own profile doesn't see themselves (the IndexNo != '" . $_SESSION['user_index'] . "' takes care of that) but sees everyone else which would be 6 other users. However, it's always showing 1 less than what it should so, in this case, it's only showing 5. If I have 5 accounts, it only shows 3 but it should show 4. Make sense?

 

I'm not really sure what could even be causing this but I posted the code so hopefully I can get some help.

 

Fair amount of code so I apologize for that but here it is:

<?php
//Friend Variables
$Friends = ' ';
$FriendCounter = 0;

if (($_GET['ViewFriends'] == '') || ($_GET['ViewFriends'] == 'all')) {
  $query = "SELECT * FROM Profile WHERE Permissions = 'Y' AND IndexNo != '" . $_SESSION['user_index'] . "' ORDER BY FirstName;";
}

if ($_GET['ViewFriends'] == 'online' ) {
  $query = "SELECT * FROM Profile WHERE Permissions = 'Y' AND ($CTime - OnlineStatus < 300) AND (IndexNo != '" . $_SESSION['user_index'] . "');";
}

if ($_GET['ViewFriends'] == 'new' ) {
  $query = "SELECT * FROM Profile WHERE Permissions = 'Y' AND (New = 'Y') AND (IndexNo != '" . $_SESSION['user_index'] . "');";
}

$result = mysql_query($query, $link)
  or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
  $FriendIndex = $row['IndexNo'];
  $FriendFirstName = $row['FirstName'];
  $FriendLastName = $row['LastName'];
  $FriendPicture = $row['Picture'];
  $FriendOnlineStatus = $row['OnlineStatus'];
  $FriendCurrentStatus = $row['CurrentStatus'];
  $FriendName = $FriendFirstName . ' ' . substr($FriendLastName, 0, 1);
  
  $FriendPictureData = explode(".", $FriendPicture);
  $FriendPictureName = $FriendPictureData[0] . 'sml';
  $FriendPicture = $FriendPictureName . '.' . $FriendPictureData[1];

  
  if ($FriendCounter == 3) {
    $Friends .=<<<EOD
    </tr>
    <tr>
EOD;
$FriendCounter = 0;
} else {
  
    $Friends .=<<<EOD
  <td width="90">
    <table width="100%" border="0">
      <tr>
        <td valign="top" align="center">
          <font class="blogh2">
            <a href="profile.php?IndexNo=$FriendIndex">$FriendName</a>
          </font>
        </td>
      </tr>

      <tr>
        <td valign="top" align="center">
         <b><a href="profile.php?IndexNo=$FriendIndex"><img src="images/users/$FriendPicture" width="64" height="81" border="0" title="$FriendCurrentStatus" alt="$FriendCurrentStatus"><a></b>
        </td>
      </tr>

      <tr>
        <td valign="top" align="center">
EOD;

  if ($CTime - $FriendOnlineStatus >= 300)  {
    $Friends .=<<<EOD
          <a href="profile.php?IndexNo=$FriendIndex"><img src="images/offline.png" border="0"></a>
EOD;

  } else {

    $Friends .=<<<EOD
          <a href="profile.php?IndexNo=$FriendIndex"><img src="images/online.png" border="0"></a>
EOD;
  }

    $Friends .=<<<EOD
        </td>
      </tr>
    </table>
  </td>
EOD;
$FriendCounter = $FriendCounter + 1;
}
}
?>

Archived

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

×
×
  • 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.