This will work for 2 levels of categories. Probably not the most efficient, but easier for users to understand the categories. You are replacing the code in account_manage.php and account_add.php
// $categories_array = array(array('id' => '', 'text' => TEXT_NONE));
// $categories_query = tep_db_query("select a.categories_id,parent_id, b.categories_name from " . TABLE_CATEGORIES . " as a," . TABLE_CATEGORIES_DESCRIPTION . " as b where a.categories_id = b.categories_id and b.language_id = " . (int)$language_id . " order by categories_name");
// while ($categories = tep_db_fetch_array($categories_query)) {
// //echo $categories['parent_id'];
// $parent_id = $categories['parent_id'];
// if ($parent_id==0)
// {
// $categories_array[] = array('id' => $categories['categories_id'],
// 'text' => $categories['categories_name']);
// } else {
// $txt=NULL;
// while ($parent_id!=0) {
// //echo $parent_id;
// $category_query = tep_db_query("select a.categories_id,parent_id, b.categories_name from " . TABLE_CATEGORIES . " as a," . TABLE_CATEGORIES_DESCRIPTION . " as b where a.categories_id = b.categories_id and a.categories_id = " . $parent_id . " and b.language_id = " . (int)$language_id . " order by categories_name");
// $category = tep_db_fetch_array($category_query);
// $txt .=$category['categories_name']."->";
// $parent_id = $category['parent_id'];
// //die($txt.$parent_id.$category['categories_id']);
// }
// $categories_array[] = array('id' => $categories['categories_id'],
// 'text' => $txt.$categories['categories_name']);
// }
// }
$categories_array = array(array('id' => '', 'text' => TEXT_NONE));
$categories_query = tep_db_query("select a.categories_id,parent_id, b.categories_name from " . TABLE_CATEGORIES . " as a," . TABLE_CATEGORIES_DESCRIPTION . " as b where a.categories_id = b.categories_id and b.language_id = " . (int)$language_id . " order by categories_name");
while ($categories = tep_db_fetch_array($categories_query)) {
//echo $categories['parent_id'];
$parent_id = $categories['parent_id'];
if ($parent_id==0)
{
$categories_array[] = array('id' => $categories['categories_id'],
'text' => $categories['categories_name']);
// NOW GET THE SUBCATS FOR THIS PARENT
$this_parent_id=$categories['categories_id'];
$this_parent_name=$categories['categories_name'];
$subcat_query = tep_db_query("select a.categories_id,parent_id, b.categories_name from " . TABLE_CATEGORIES . " as a," . TABLE_CATEGORIES_DESCRIPTION . " as b where parent_id=" . $this_parent_id . " and a.categories_id = b.categories_id and b.language_id = " . (int)$language_id . " order by categories_name");
while ($subcat = tep_db_fetch_array($subcat_query)) {
$categories_array[] = array('id' => $subcat['categories_id'],
'text' => $this_parent_name ."->". $subcat['categories_name']);
}
}
}