Mystixs Posted October 15, 2007 Share Posted October 15, 2007 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>"; } Quote Link to comment https://forums.phpfreaks.com/topic/73304-not-working-right/ Share on other sites More sharing options...
willpower Posted October 15, 2007 Share Posted October 15, 2007 it appears that you have closed your (sub)while loop to early and it does not include the avatar so it will keep returning the same one. Quote Link to comment https://forums.phpfreaks.com/topic/73304-not-working-right/#findComment-369858 Share on other sites More sharing options...
Mystixs Posted October 15, 2007 Author Share Posted October 15, 2007 Umm, ok, but I still don't understand how to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/73304-not-working-right/#findComment-369867 Share on other sites More sharing options...
Mystixs Posted October 15, 2007 Author Share Posted October 15, 2007 Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/73304-not-working-right/#findComment-370027 Share on other sites More sharing options...
BlueSkyIS Posted October 15, 2007 Share Posted October 15, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/73304-not-working-right/#findComment-370043 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.