If you use IndexScript for your directory, you must see something wrong with indexScript directory count method. To help you understand this problem I’ll give you an example.
If no URL under Computer directory.
Computer (0) ? This should be Computer (5)
-Hardware (3)
*URL1
*URL2
*URL3
-Software (2)
*URL1
*URL2
If any URL under Computer directory.
Computer (2) ? This should be Computer (7)
*URL1
*URL2
-Hardware (3)
*URL1
*URL2
*URL3
-Software (2)
*URL1
*URL2
Find this code :
$sql = “select count(*) from dir_url where cat_id = ” . $row['cat_id'];
$rst_cnt = mysql_query($sql);
$row_cnt = mysql_fetch_array($rst_cnt);
print “ (” . $row_cnt[0] . “)”;
Replace with this code :
$sql = “select count(*) from dir_url where cat_id = ” . $row['cat_id'];
$rst_cnt = mysql_query($sql);
$row_cnt = mysql_fetch_array($rst_cnt);
$sum_url=0;
$sql1 = “select * from dir_cat where parent_id=’$row[cat_id]‘”; //search cat_id with same parent_id
$query = mysql_query($sql1);
while($all = mysql_fetch_array($query))
{
$sql2 = “select count(*) from dir_url where cat_id = ‘$all[cat_id]‘”;
$query2 = mysql_query($sql2);
$count_url = mysql_fetch_array($query2);
$sum_url=$sum_url+$count_url[0];
}
$sum_all_url=$sum_url+ $row_cnt[0];
print “ (” . $sum_all_url . “)”;
Now you should see like this :
Computer (7)
*URL1
*URL2
-Hardware (3)
*URL1
*URL2
*URL3
-Software (2)
*URL1
*URL2
Tags: