Hi,
I would really like to add some more functions to my page and that requires optimziing the currect two queries that I have on my main page.
Here is the code so far:
<?
// CONNECTED ALREADY BY INCLUDING CONNECT FILE
// SELECT DATABASE
mysql_select_db("petesmc_articles");
// QUERY
$result = mysql_query("SELECT DATE_FORMAT(DateAdded, '%D %M, %Y') AS Date, " .
"AID, Title, Name, articles.Description FROM articles, authors " .
"WHERE AuthorID=ID ORDER BY DateAdded DESC LIMIT 6");
print "<table>";
// START TABLE LOOP VARIABLES
$numcols = 2;
$count = 1;
// LOOP THE QUERY RESULT
while ($row = mysql_fetch_array($result)) {
$aid = $row["AID"];
$date = $row["Date"];
$title = $row["Title"];
$description = $row["Description"];
$name = $row["Name"];
// PRINT OUT RESULTS
if ($count % $numcols == 0) {
print "<td valign=\"top\"><a href='article.php/aid/$aid'>$title</a><br>" .
"<font size='1' color='#808080'>by $name, $date<br><font color=\"black\">$description</font></font><br><br></td></tr><tr>";
}
else {
print "<tr><td valign=\"top\"><a href='article.php/aid/$aid'>$title</a><br> " .
"<font size='1' color='#808080'>by $name, $date<br><font color=\"black\">$description</font></font></td>";
}
$count++;
}
print '</tr></table>';
?></blockquote>
<br> <font size="4"><b>Articles</b></font> <blockquote>
<?
$articles = mysql_query("SELECT DATE_FORMAT(DateAdded, '%D %M, %Y') AS Date, " .
"articlelist.ID, Title, Name, articlelist.Description FROM articlelist, authors " .
"WHERE AuthorID=authors.ID ORDER BY DateAdded DESC LIMIT 2");
while ($rowa = mysql_fetch_array($articles)) {
$id = $rowa["ID"];
$datea = $rowa["Date"];
$titlea = $rowa["Title"];
$descriptiona = $rowa["Description"];
$namea = $rowa["Name"];
print("</p><p><a href='articles.php/aid/$id'><font size='+1'>$titlea</font></a><br> " .
"<font size='1' color='#808080'>by $namea, $datea</font><br>$descriptiona</p>"); }
?>
Does anyone know how to combine this into 1 optimized query that WILL reduce the query/load time. I want to do this because it is unacceptable for me to have over two queries and what I want to do requires that I have another one.
So I must reduce this into 1 query that loads FAST!!!
Please if anyone can help me out here it is greatly appreciated.
Thank You so much,
-Peter
http://www.codngclick.com