Jump to content

Not working right


Mystixs

Recommended Posts

Hey Guys, me again. I got another problem. Anyway here is what I am trying to do. I have 3 Friends on the profile, I want it to give an avatar, and a Name for each one. Well, it does somewhat of what I want. It gives 3 avatars and 3 names, but they are all the same. What am I doing wrong?

Here is my code:

 

if(isset($_SESSION[username]))
{
$result = mysql_query("SELECT * FROM TheLoop_Users WHERE Username = '$_SESSION[username]'");
while($row = mysql_fetch_array($result))
echo "<hr /><center><h2>".$row['FirstName']." ".$row['LastName']."'s Profile</h2></center><br />";
echo "<table border='1'>
<tr>";
$result = mysql_query("SELECT * FROM TheLoop_Users WHERE Username = '$_SESSION[username]'");
while($row = mysql_fetch_array($result))
echo "<td valign='top'><b>Username: </b>".$_SESSION['Username']."<br /><b>User ID: </b>".$_SESSION['ID']."<br /><img src='".$row['Avatar']."' /><br /><center><a href='MyProfile.php?action=ChangeAvatar'>Change Avatar</a></center></td><td valign='top'>".$_SESSION[username].", you have 0 New Messages, 0 New Friend Requests, and 0 New Profile Views.</td><td valign='top'><b>Friends</b>";
$result = mysql_query("SELECT * FROM TheLoop_Users WHERE id = '$Friendid'");
while($row = mysql_fetch_array($result))
{
$Avatar = $row['Avatar'];
$Name = $row['FirstName'];
}
echo "<br />You have ".$Friends." Friends<br />";
$result = mysql_query("SELECT * FROM TheLoop_Friends WHERE Accepted = '1'");
while($row = mysql_fetch_array($result))
{
echo "<img src='".$Avatar."' /><br /><center>".$Name."</center>";
}
echo "</td></tr>
</table>";
}
else
{
echo "<center>You must be Logged In to view your profile.</center>";
}

Link to comment
Share on other sites

for one, you keep over-writing the variable $result. you use it before a loop, then inside the loop you overwrite it with another query result, then create a loop in which is is again over-written. as a start, i would change the variables so you don't keep over-writing them. use $result for the first, $result2 for the second, etc.

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.