0
votes

I'm trying to make a simple posts feed that shows the top 10 posts in order of the dates tied to them (earliest date to oldest date). So far I only have code that displays the latest post.

postdata = mysqli_query($connection, 'SELECT * FROM posts ORDER BY date DESC LIMIT 10;');
$postdata = mysqli_fetch_assoc($postdata);
$userid = $_SESSION['userid'];
echo 'ID: ' . $postdata['id'].' | '.$postdata['date'].' | '.mysqli_fetch_assoc(mysqli_query($connection, "SELECT * FROM users WHERE userid = '$userid'"))['username'] . " | " . $postdata['content'];

Would anybody be able to help?