I have been at this all day, maybe its writers block or just my schere un knowing. i made a script that i hope would give me only the 9 most recent post but for some reason i made like a view thread script that gives me all post, any idea on how i can fix this, heres my script, its the view thread script i started with, my mods just made it slower with the same result, any ideas would help. im trying to make a script wich would display only the 9 most rescent news articled posted. thanks
// Build query to get thread
$query = "SELECT * FROM forumPosts WHERE threadID = $threadID ORDER BY posted ASC";
// Execute query
$result = @mysql_query($query);
// If query failed...
if (!$result) {
echo "Couldn't fetch posts from database";
}
// Find out how many posts in this thread
$postCount = @mysql_num_rows($result);
// Setup our variable to hold output
$output = "&postCount=$postCount";
// For each post returned...
for ($count = 0; $count < $postCount; $count++) {
// Extract post details from database
$post = mysql_fetch_array($result);
$userID = $post['userID'];
$message = stripslashes($post['message']);
$posted = strftime("%d/%m/%y %H:%M", $post['posted']);
// Build and execute query to fetch username and
// title of the author of this post
$query = "SELECT username, title FROM forumUsers WHERE userID = $userID";
$result2 = @mysql_query($query);
// Extract user information from results
$user = @mysql_fetch_array($result2);
$username = $user['username'];
$userTitle = $user['title'];
// Add post details to output
$output .= "&post" . $count . "Author=" . urlencode($username);
$output .= "&post" . $count . "Date=" . urlencode($posted);
$output .= "&post" . $count . "UserTitle=" . urlencode($userTitle);
$output .= "&post" . $count . "Message=" . urlencode($message);
}
// Output all posts.... I think this is where i need to do the 9 most rescent or maybe above
echo $output;
Any help would be greatly appreciated