Hi
sorry for my bad English
I have this queries but when I using num_queries show over 40 for this code!!
how can I optimize it for best performance
category table is : ".$prefix."_modules_categories
item table is : ".$prefix."_modules
$display = $openclose;
if ($display == 0) {
$show = "none";
$catimg = "<img src=\"$closedimg\" align=\"absmiddle\" border=\"0\">";
} else {
$show = "show";
$catimg = "<img src=\"$openimg\" align=\"absmiddle\" border=\"0\">";
}
//Categories
$result = $db->sql_query("select mcid, mcname FROM ".$prefix."_modules_categories WHERE visible='1' ORDER BY mcposition");
//$coin=0;
global $multilingual, $currentlang;
while ($row = $db->sql_fetchrow($result)) {
$mcid = $row['mcid'];
$mcname = $row['mcname'];
//$coin++;
$mcname1 = $mcname;
if(strlen($mcname1) == 0){
if ($multilingual == 1) {
include("modules/languages/lang-".$currentlang.".php");
$mcname = "$mcnamed[$mcid]";
} else {
include("modules/languages/lang-english.php");
$mcname = "$mcnamed[$mcid]";
}
}else{
$mcname = "$mcname1";
}
$content .= "</div><table border=0 cellpadding='1' cellspacing=1><tr><td width='16'><a id=\"x".$mcname."\" href=\"javascript:Toggle('".$mcname."','$align');\">$catimg</a></td><td><b>".$mcname."</b></table>\n";
$content .= "<div id=\"".$mcname."\" style=\"display: $show; margin-left: 1em;\">\n";
$result2 = $db->sql_query("SELECT title, custom_title, view, url FROM " . $prefix . "_modules WHERE active='1' AND inmenu='1' AND title!='$def_module' AND mcid='$mcid' ORDER BY custom_title ASC");
while ($row = $db->sql_fetchrow($result2)) {
$title = $row['title'];
$custom_title = $row['custom_title'];
$view = $row['view'];
$url = $row['url'];
$arraymodules[] = "$title:$custom_title:$view:$url";
$m_title = $title;
$m_title2 = ereg_replace("_", " ", $m_title);
include("modules/".$title."/language/lang-".$currentlang.".php");
if ($custom_title != ""){$m_title2 = $custom_title;}else{
if(strlen($mudulename) != 0){
$custom_title = "$mudulename";
}
$m_title2 = $custom_title;
}
if ($m_title != $main_module) {
$showit = 0;
switch($view){
case 0: // All users case
$showit = 10;
break;
case 1: // Registered user access
if (is_user($user) || is_admin($admin)) $showit = 1;
break;
case 2: // Admin only access
if (is_admin($admin)) $showit = 2;
break;
default: // Subscriber only access
if (is_user($user) || paid()) $showit = 3;
break;
}
global $db , $prefix;
$rowz = $db->sql_fetchrow($db->sql_query("SELECT gtset FROM ".$prefix."_config"));
$gtset = intval($rowz['gtset']);
if ($showit != 0) {
$adds = $_SERVER['SERVER_NAME'];
if ($url != "" AND $gtset != 0) {
$content .= "<table border=0 cellpadding='1' cellspacing=1><tr><td width='16'><img src=\"$arrowimg\" align=\"absmiddle\" border=\"0\"></td><td><a href=\"$url\" title=\"$m_title2\" onMouseOver=\"self.status=' $m_title2 ';return true\" onmouseout=\"self.status='';return true\">$m_title2</a></td></tr></table>\n";
} else {
$content .= "<table border=0 cellpadding='1' cellspacing=1><tr><td width='16'><img src=\"$arrowimg\" align=\"absmiddle\" border=\"0\"></td><td><a href=\"modules.php?name=$m_title\" title=\"$m_title2\" onMouseOver=\"self.status=' $m_title2 ';return true\" onmouseout=\"self.status='';return true\">$m_title2</a></td></tr></table>\n";
}
}
}
$mudulename = "";
}
}
$content .= "</div>";
$db->sql_freeresult($result);
$db->sql_freeresult($result1);