I'm trying to write a simple database driven forum.
This page is a view of the posts from a particular topic. It's pulling information from a mySql database from 2 tables (1 holds the author information, another holds the posts). At the moment my script displays the post information quite easily. The post information contains a user id that I want to run a second query on and draw all the users information (avatars, username etc).
Is there a way to query the user information into an array and then match the user id to elements in the array so I don't have to run a query for each post to retrieve the user information?
here's part of the code so far that draws the post information:
$post_query = $db->query("SELECT * FROM forum_posts WHERE topic_id='$topicid' ORDER BY post_date ASC LIMIT $from, $max_results");
while ($post = mysql_fetch_array($post_query)) {
/* post information here */
}
Any help would be appreciated. 🙂