我希望我的主页能够显示我的朋友的帖子,但是发生了什么,我看到帖子列added_by
上的更新是空白的,但是对于那些列有名称的帖子,这些帖子没有显示。我试图定义$ username但是没有用。这是我正在使用的2个表;第一个是
posts (id,body,date_added,added_by,user_posted_to)
第二个是
users (id,username,first_name,last_name,email,password,sign_up_date,activated,bio,profile_pic,friend_array,closed).
这是我的home.php:
<?php
//If the user is logged in
$getposts = $mysqli->query("SELECT * FROM posts
INNER JOIN users ON posts.added_by = users.friend_array
WHERE posts.added_by = '$username'
ORDER BY friend_array DESC LIMIT 10") or die(mysqli_error($mysqli));
while ($row = mysqli_fetch_assoc($getposts)) {
$id = $row['id'];
$body = $row['body'];
$date_added = $row['date_added'];
$added_by = $row['added_by'];
$user_posted_to = $row['user_posted_to'];
这是我的示例发布数据。我可以看到Post id no.11但我看不到12-15。
id body date_added added_by user_posted_to
11 hahaha 2015-08-25 Jamo
12 hello 2015-08-25 Jamo Jamo
13 hi 2015-08-26 Cess Atis
14 hehe 2015-08-26 Anto Anto
15 me 2015-08-26 Anto Gilly
以下是我的示例用户数据:
id username first_name last_name email password sign_up_date activated bio profile_pic friend_array closed
1 Jamo James Kariuki kadinya@yahoo.com 894416aea718e7c44a126581dd017588 2015-08-18 0 hello C2LTjo79O4I63Gt/004.jpg Cess,Anto,Gilly Yes
2 Cess Cecilia Nyambura cess@gmail.com 894416aea718e7c44a126581dd017588 2015-08-18 0 welcome 3mlbDJSXoThHvEi/023.jpg Gilly,Atis,Jamo no