My webhost said that my site's MySQL coding had a lot of nested queries, which was placing a lot of stress on the server.
One instance of this is where the code grabs the 8 most recent posts made on the forums, retrieving data from two tables: f_posts (which has all the posts listed with associated threadid) and f_threads (which has all the threads listed with associated thread subjects, posting date, thread starter and so on):
Code: Select all
<?
$result = mysql_query("SELECT * FROM f_posts ORDER BY postid DESC LIMIT 0, 8");
while($info = mysql_fetch_object($result)) {
print "<p>in <a href='forums/view.php?threadid=" . $info->threadid . "'>";
$tresult = mysql_query("SELECT * FROM f_threads WHERE threadid='$info->threadid'");
$tinfo = mysql_fetch_object($tresult);
print stripslashes($tinfo->subject). "</a>";
print "<br>by " . stripslashes($info->author);
}
?>My webhost suggested using foreach, but I'm not entirely sure how that would work. I'm still pretty new to this.
Any help is appreciated, thanks!