我有一個朋友的列表,我想顯示在每個配置文件頁面,其中用戶是他們的朋友,但問題是,當我使用螢火蟲系統顯示一個ID和與默認piture列表中的朋友沒有顯示使用PHP和MySQL
所以我認爲錯誤是在foreach循環任何人都可以幫助我?
PHP代碼:
<?php
//***********************Displaying Friend List*************************//
$friendListTitle = "";
$friendList = "";
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
/*$frnd1 = $friendArray[0];
$frnd2 = $friendArray[1];
/*$frnd3 = $friendArray[2];
$frnd4 = $friendArray[3];
$friendList .='<div style="background-color:"#CCC";>'.$frnd1.'<br />'.$frnd2.'</div>';*/
$i=0;
$friendList .='<div style="background-color:"#CCC"; >';
foreach($friendArray as $key => $value)
{
$i++;
$check_pic = "members/$value/image01.jpg";
if(file_exists($check_pic))
{
$frnd_pic = '<a href="profile.php?id='.$value.'"><img src = \"$check_pic\" width = \"30px\"; border = \"1\"/></a>';
}
else
{
$frnd_pic = '<a href="profile.php?id='.$value.'"><img src = "members/0/image01.jpg" width = \"30px\" border = \"1\"/></a> ';
}
$sqlName = mysql_query("SELECT first_name, last_name FROM members WHERE user_id= '$value' LIMIT 1") or die(mysql_error());
while($row = mysql_fetch_array($sqlName))
{
$fname = $row['first_name'];
$lname = $row['last_name'];
$friendList = '<div title="'.$fname.' '.$lname.'">'.$frnd_pic.'</div>';
}
}
$friendList .='</div>';
}
?>
我不得不修改我的問題,修改代碼來看看 – user2378026
,仍然具有相同problemmmmmm – user2378026