This is for an ecommerce site. This is supposed to display a complete list of categories with their ids next to it. The names should be like this
Animals : Pet Supplies : Dog Supplies : Dog Bowls, Feeders & Waterers 41
The problem is that each parent category with subcategories gets skipped, showing only the subcategories.
I need this to display all of them.
Thanks
function setCategories()
{
$sql_select_categories = $this->db->query("SELECT c.category_id FROM " . DB_PREFIX . "categories c WHERE
(SELECT count(*) FROM " . DB_PREFIX . "categories p WHERE p.parent_id=c.category_id)=0");
while ($category_details = $this->db->fetch_array($sql_select_categories))
{
$this->categories[] = array('id' => $category_details['category_id'], 'name' => $this->categories_array[$category_details['category_id']][0]);
}
}