$categories_descriptiontable = $oostable['categories_description']; $categories_result = $dbconn->Execute("SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.access, c.categories_status FROM {$categoriestable} c, {$categories_descriptiontable} cd WHERE c.categories_id = cd.categories_id and cd.categories_languages_id = '" . intval($_SESSION['language_id']) . "' and cd.categories_name like '%" . $_GET['search'] . "%' ORDER BY c.sort_order, cd.categories_name"); } else { $categoriestable = $oostable['categories']; $categories_descriptiontable = $oostable['categories_description']; $categories_result = $dbconn->Execute("SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.access, c.categories_status FROM {$categoriestable} c, {$categories_descriptiontable} cd WHERE c.parent_id = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.categories_languages_id = '" . intval($_SESSION['language_id']) . "' ORDER BY c.sort_order, cd.categories_name"); } while ($aCategories = $categories_result->fields) { $categories_count++; $rows++; // Get parent_id for subcategories if search if (isset($_GET['search'])) { $categories = $aCategories['parent_id']; } if ((!isset($_GET['cID']) && !isset($_GET['pID']) || isset($_GET['cID']) && $_GET['cID'] == $aCategories['categories_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') { $category_childs = array('childs_count' => oos_childs_in_category_count($aCategories['categories_id'])); $category_products = array('products_count' => oos_products_in_category_count($aCategories['categories_id'])); $cInfo_array = array_merge($aCategories, $category_childs, $category_products); $cInfo = new objectInfo($cInfo_array); } if (isset($cInfo) && is_object($cInfo) && $aCategories['categories_id'] == $cInfo->categories_id) { echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . oos_href_link_admin($aFilename['categories'], oos_get_path($aCategories['categories_id'])) . '\'">' . "\n"; } else { echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . oos_href_link_admin($aFilename['categories'], 'categories=' . $categories . '&cID=' . $aCategories['categories_id']) . '\'">' . "\n"; } ?> <td class="dataTableContent"><?php echo '<a href="' . oos_href_link_admin($aFilename['categories'], oos_get_path($aCategories['categories_id'])) . '">' . oos_image(OOS_IMAGES . 'icons/folder.gif', ICON_FOLDER) . '</a> <b>' . ' #' . $aCategories['categories_id'] . ' ' . $aCategories['categories_name'] . '</b>'; ?> </td> <td class="dataTableContent" align="center"> </td>
function oos_childs_in_category_count($categories_id) { $categories_count = 0; // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $categoriestable = $oostable['categories']; $query = "SELECT categories_id\n FROM {$categoriestable}\n WHERE parent_id = '" . (int) $categories_id . "'"; $result =& $dbconn->Execute($query); while ($categories = $result->fields) { $categories_count++; $categories_count += oos_childs_in_category_count($categories['categories_id']); // Move that ADOdb pointer! $result->MoveNext(); } // Close result set $result->Close(); return $categories_count; }