$whereStatement = " WHERE `visible`='Y'";
if (isAdmin()) $whereStatement = '';
-$result = SQL_QUERY("SELECT id, cat FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort`", __FILE__, __LINE__);
-$cats = SQL_NUMROWS($result);
+// Get all categories
+$result = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats`".$whereStatement." ORDER BY `sort` ASC", __FILE__, __LINE__);
-if ($cats > 0) {
+// Get num rows
+$numCategories = SQL_NUMROWS($result);
+
+if ($numCategories > 0) {
$LEAST = false;
if (isFormSent()) {
$cnt = '0';
if ($joined != 'Y') $cnt++;
} // END - foreach
- if (($cats - $cnt) < getConfig('least_cats')) {
+ if (($numCategories - $cnt) < getConfig('least_cats')) {
unsetPostRequestParameter('ok');
$LEAST = true;
} // END - if
} // END - if
// Put some data into constants for the template
- $content['rows'] = ($cats*2+4);
+ $content['rows'] = ($numCategories * 2 + 4);
// Load header template
loadTemplate('member_cats_header', false, $content);