Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

counting categories


goring_gap

Recommended Posts

Posted

Hello,

 

I want to count the top level categories ONLY.

 

I am using count(tep_get_categories()) to count the number of categories.

 

Does anyone know how to modify the call to tep_get_categories() to give info ONLY on top level categories, because by default it seems to count all categories parent and child alike.

 

Hope this makes sense!

 

Cheers

Simon

Posted
Hello,

 

I want to count the top level categories ONLY.

 

I am using count(tep_get_categories()) to count the number of categories.

 

Does anyone know how to modify the call to tep_get_categories() to give info ONLY on top level categories, because by default it seems to count all categories parent and child alike.

 

Hope this makes sense!

 

Cheers

Simon

 

 

function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') {

global $languages_id;

 

if (!is_array($categories_array)) $categories_array = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = 0 and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$categories_array[] = array('id' => $categories['categories_id'],

'text' => $indent . $categories['categories_name']);

 

}

 

return $categories_array;

}

Treasurer MFC

  • 3 weeks later...
Posted
function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') {

    global $languages_id;

 

    if (!is_array($categories_array)) $categories_array = array();

 

    $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = 0 and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

    while ($categories = tep_db_fetch_array($categories_query)) {

      $categories_array[] = array('id' => $categories['categories_id'],

                                  'text' => $indent . $categories['categories_name']);

 

    }

 

    return $categories_array;

  }

 

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...