I am trying to make a follower post kind of thing in PHP and whenever Ajax refreshes my page, they are not in the correct order. The output I am getting is that the content of a post always sticks to whoever posts it, for example if I post something, then someone else posts something, then I post something again, it should be like this my post, their post, my post, instead it is like this, my post, my post, their post. So I am basically having an issue ordering what is coming out of the while loop. Here is the code I have.
<?php
require("scripts/connect.php");
session_start();
$my_id = $_SESSION["wave"]["id"];
$query = mysql_query("SELECT * FROM `follows` WHERE `follower_id` = '$my_id'")or die(mysql_error());
if(mysql_num_rows($query) >= 1)
{
while($row = mysql_fetch_assoc($query))
{
$following = $row["following_id"];
$new_query = mysql_query("SELECT * FROM `posts` WHERE `user_id` = '$following' ORDER by `id` DESC");
while($new_row = mysql_fetch_assoc($new_query))
{
echo $new_row["username"]."<br />".$new_row["content"]."<hr>";
}
}
}else
{
echo "You are not following anyone; There are no new Ripples for you.";
}
?>
order by dateandtime
– Feroz Akbar May 30 at 3:50order by id desc
– Feroz Akbar May 30 at 3:54