0
對不起,長標題。 我有一個註冊用戶的列表,一些有個人資料圖片,一些沒有。 的問題是,如果用戶1登錄,然後在用戶列表中,每個人都有相同的外形圖像作爲用戶1從查詢中調用默認圖像時獲取每個用戶的獨特圖像
但如果我從查詢中刪除我的默認來電顯示,每個用戶都會獲得自己的圖片,但default.jpg圖片不起作用。 我可以刪除查詢並在頁面上使用if語句,但我真的想避免這種情況。
function fetch_users($uid){
$query = $this->link->query("SELECT user.id, user.username, user.email,
userdetails.profile_img,userdetails.firstname,
userdetails.lastname,userdetails.location,following.follow_id
FROM user
LEFT JOIN userdetails ON user.id = userdetails.user_id
LEFT JOIN following ON user.id = following.follow_id
WHERE user.id != '{$uid}' ");
$users = array();
while(($row = $query->fetch(PDO::FETCH_ASSOC)) !== FALSE) {
#The row that mess up things#----->$row['profile_img'] = file_exists("img/{$uid}.jpg") ? "img/{$uid}.jpg" : "img/default.jpg" ;
$users[] = $row;
}
return $users;
}
這樣一個美麗的解決方案:),經過一些調整後,工作得很好! 真的很不錯。謝謝。 – Dymond 2013-04-25 14:32:15