вашите изображения и div, които съдържат записите на приятели, се заменят със следващия запис, така че да показват последния запис на вашите приятели. опитайте това може да ви помогне
$friendList = "";
$friendListTitle="";
if($friend_array!="")
{
$friendArray = explode(",", $friend_array);
$friendArray = array_slice($friendArray,0,6);
$friendCount = count($friendArray);
var_dump($friendCount);
$friendListTitle = '<div class="title"> '.$username.'\'s Friends('.$friendCount.')</div>';
//iterating to retrieve what it's needed as values
$i=0;
$friendList ='<div style="background-color:"#CCC"; >';
foreach($friendArray as $frndlist => $value)
{
$i++;
$check_pic = 'members/'.$value.'/image01.jpg';
if(file_exists($check_pic))
{
//storing each friend images separately
$frnd_pic[$i] = '<a href="profile.php?user_id='.$value.'"><img src = "'.$check_pic.'" width = "52px" border = "1"/></a>';
}
else
{
$frnd_pic[$i] = '<a href="profile.php?user_id='.$value.'"><img src = "members/0/image01.jpg" width = "52px" border = "1"/></a> ';
}
$sqlName = mysql_query("SELECT first_name, last_name FROM members WHERE user_id= '$value'LIMIT 1") or die(mysql_error());
if ($row = mysql_fetch_array($sqlName, MYSQL_ASSOC))
{
$fname = $row['first_name'];
$lname = $row['last_name'];
$friendList .= '<div title="'.$fname.' '.$lname.'">'.$frnd_pic[$i].'</div>';
}
}
$friendList.='</div>';
}