Here's another to ponder on .
Problem Number 3
PHP Code:
# Categories and subcategories column
$parentcatquery = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "articles_category WHERE parentcategory=0 ORDER BY categoryorder");
if ($DB_site->num_rows($parentcatquery)>0)
{
while($parentcatrow=$DB_site->fetch_array($parentcatquery))
{
$parentid = $parentcatrow["articles_categoryid"];
$catname = $parentcatrow["categoryname"];
$parentcat = $parentcatrow["parentcategory"];
eval('$catlistbit .= "' . fetch_template('vbArticles_categorybit') . '";');
eval('$catlistbit .= "' . fetch_template('vbArticles_categorybit_pre') . '";');
$subcatquery = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "articles_category WHERE parentcategory = $parentid ORDER BY categoryorder");
if ($DB_site->num_rows($subcatquery)>0)
{
while($subcatrow=$DB_site->fetch_array($subcatquery))
{
$subcatid=$subcatrow["articles_categoryid"];
$subcatname=$subcatrow["categoryname"];
eval('$catlistbit .= "' . fetch_template('vbArticles_childcatbit') . '";');
}
}
eval('$catlistbit .= "' . fetch_template('vbArticles_categorybit_post') . '";');
}
}
I am trying to get the categories and then the subcategories of the parent category.
Is there anyway I can change things around to optimize what I am trying to do ?
As it is, this is probably the code portion contributing to the massive amount of queries ( testing : 32 queries at this time, with 4 parent cats, each with 5,4,1,6 subcats respectively )