kkjay 2 Light Poster

Hi guys, im trying to develop a social networking application and im having some trouble showing a user's selected avatar. Every users can upload pictures and there is a field called avatar and when this is set to 1, it is the users avatar pic. Only one pic can be an avatar.

My PHP code:

<div class="interactContainers" id="pal_requests">
<?php
$pal_requests = "SELECT * FROM pal_requests WHERE mem2='$user_id' ORDER BY pal_request_id ASC LIMIT 50";
$pal_request_query = mysql_query($pal_requests) or die(mysql_error());
$pal_request_num_rows = mysql_num_rows($pal_request_query);
if($pal_request_num_rows < 1)
{
	echo '&nbsp;You have no Pal requests at this time.';
	exit();
}
else
{
	while($row = mysql_fetch_array($pal_request_query))
	{
	$request_id = $row["pal_request_id"];
	$mem1 = $row["mem1"];
	$query_user = "SELECT user_first_name, user_last_name, picture_thumb_url FROM users LEFT JOIN picture ON users.user_id = picture.user_id
	AND picture.avatar=1 WHERE users.user_id='$mem1' LIMIT 1";
	$user_info = mysql_query($query_user, $connections) or die(mysql_error());
	}			 
}
?> 
<?php
while ($row = mysql_fetch_array($user_info)){ $requesterFirstName = $row["user_first_name"]; $requesterLastName = $row["user_last_name"]; }
{
	if(!empty($row["picture_thumb_url"]))
	{
		$avatar = '<a href="user_view.php?user_id2=' . $mem1 . '"><img src="/NNL/User_Images/Thumbs/$row["picture_thumb_url"]" width="50" height="50" border="0"/></a>';
	}
	else
	{
		$avatar = '<a href="user_view.php?user_id2=' . $mem1 . '"><img src="/NNL/Style/Images/default_avatar.png" width="50" height="50" border="0"/></a>';
	}
echo '<hr />
<table width="100%" cellpadding="5">
 <tr>
   <td width="17%" align="left"><div style="overflow:hidden; height:50px;">'. $avatar .'</div></td>
   <td width="83%"><a class="ordinary_text_12_blue "href="user_view.php?user_id2=' . $mem1 . '">'. $requesterFirstName .' '.   $requesterLastName .'</a> wants to be your Pal<br /><br />
   <span id="req' . $request_id . '">
   <a class="ordinary_text_12" href="#" onclick="return false" onmousedown="javascript:acceptFriendRequest(' . $request_id . ');" >Accept</a>
   &nbsp; &nbsp; OR &nbsp; &nbsp;
   <a class="ordinary_text_12" href="#" onclick="return false" onmousedown="javascript:denyFriendRequest(' . $request_id . ');" >Deny</a>
   </span></td>
 </tr>
</table>';    
}
?> 
</div>                   

The default avatar is being called all the time even though a user has selected their own avatar. Can someone tel me what im doing wrong?
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.