I dont know if I lost the information in my brain, or if I never had it, but I have created a tweet so a user can follow other users.
The problem now is that every user display the same information.
I Was trying to add WHERE $_SESSION['uid']
to my query but that doesn't help do the trick.
Still shows the same info. Any tips ?
<?php
foreach(fetch_follotweets() as $tweet){
echo $tweet['firstname'];
echo $tweet['lastname'];
echo $tweet['username'];
echo $tweet['date'];
echo $tweet['profile_img'];
$tweet['message'];
}
function fetch_follotweets(){
global $db;
$query = $db->query(" SELECT
user.email,
user.username,
tweets.message,
tweets.date,
userdetails.profile_img,
userdetails.firstname,
userdetails.lastname,
following.id,
following.user_id,
following.follow_id
FROM user
JOIN userdetails
ON user.id = userdetails.user_id
JOIN tweets
ON userdetails.user_id = tweets.user_id
JOIN following
ON following.follow_id
WHERE following.follow_id = tweets.user_id AND
user.id='{$_SESSION['uid']}
ORDER BY tweets.date DESC");
$tweet = array();
while(($row = $query->fetch(PDO::FETCH_ASSOC)) !==FALSE) {
$tweet[] = $row;
}
return $tweet;
}
?>