Ok,
I'm running a PHP script called phpOnDirectory on thsi website i'm creating so that people can have their companies listed in our directory. Currently, the script displayes the directory in a left-hand column, and the results in the center column. When you access a category, the script displays the number of listings withing that category in parenthesis next to the title. What my client wants is to take that out(easy enough) and have the totals listed next to the categories on the left.
The script is divided into 3 parts. There's the maintemplate.inc.header.php, maintemplate.inc.footer.php and directory.php. I tried to pull the code that displays the total from directory.php and paste it into the header, but it generated errors. Here's the PHP code from maintemplate.inc.header.php:
<?php
# directory menu
$categories=mysql_query("SELECT DISTINCT(cat_parent) FROM dir_categories",$link);
while ($directory_menu_top=mysql_fetch_object($categories)) {
print("<b><div class='sideNavHead'>$directory_menu_top->cat_parent</div></b>");
$sub_categories=mysql_query("SELECT cat_child, cat_id FROM dir_categories WHERE cat_parent = '$directory_menu_top->cat_parent'",$link);
while ($directory_menu=mysql_fetch_object($sub_categories)) {
$sub_category.="<a href='$CONST_LINK_ROOT/directory.php?cat=$directory_menu->cat_id' class='mainlink'>$directory_menu->cat_child (<?php echo $total ?>)</a><br>";
}
print("<div class='sideNavBody'>$sub_category</div>");
$sub_category="";
}
?>
And here is the code from the directory.php file:
<?php
include_once('includes/db_connect.php');
if (!file_exists($CONST_INCLUDE_ROOT.'/banner.inc.php')){
echo 'File banner.inc.php does not exists!';
exit;
}
include_once('banner.inc.php');
include_once('pagerank.php');
if (isset($HTTP_GET_VARS['cat'])) $cat=$HTTP_GET_VARS['cat'];
$result=mysql_query("SELECT * FROM dir_categories WHERE cat_id = $cat",$link);
$category_info=mysql_fetch_object($result);
$page_title=$category_info->cat_child;
if (!isset($HTTP_GET_VARS['page'])) $page=0; else $page=$HTTP_GET_VARS['page'];
$result=mysql_query("SELECT COUNT(*) AS total FROM dir_site_list WHERE cat_id=$cat AND site_sponsor='N'",$link);
$site_list=mysql_fetch_object($result); $total=$site_list->total;
include('Templates/maintemplate.header.inc.php');
?>
And finally, this is the snippet that calls the name and total:
<?php print("$category_info->cat_child"); ?> (<?php echo $total ?>)
Now, can someone tell me what to put in the maintemplate.inc.header.php file so that it will display the totals next to each individual category? Your help is greatly appreciated!