<?
function tot_cat($pid)
{
require 'include/configurations.php';
$pid=rtrim($pid);
$count_item_sql="select productid from auction_details where category_id = '$pid' and status='Active'";
$count_item_res=mysql_query($count_item_sql);
$count_item_total=mysql_num_rows($count_item_res);


$sub_sql="select * from site_categories where category_head_id='$pid'";
$sub_res=mysql_query($sub_sql);
        
		while($row=mysql_fetch_array($sub_res))
        {

$count_item_sql="select productid from auction_details where status='Active' and category_id=".$row[category_id];
$count_item_res=mysql_query($count_item_sql);
$count_item=mysql_num_rows($count_item_res);
$count_item_total = $count_item_total + $count_item;
}
echo "$count_item_total";
}
?>