Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / admin / what-list_cats.php
index 53cdead13af9c8d193358f96a4198202b1cd4e53..919e203a054c10c25657ff9fad3febd72a3374ac 100644 (file)
@@ -17,7 +17,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -48,10 +48,14 @@ addYouAreHereLink('admin', __FILE__);
 $CATS = '';
 
 if (isFormSent('add')) {
+       // Default message
+       $content = '<span class="bad">{--CATEGORY_ALREADY_EXISTS--}</span>';
+
        // Add a new category
        $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `cat`='%s' LIMIT 1",
                array(postRequestElement('catname')), __FILE__, __LINE__);
-       if (ifSqlHasZeroNums($result)) {
+
+       if (ifSqlHasZeroNumRows($result)) {
                // Category does not exists, we simply add it...
                sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_cats` (`cat`, `visible`, `sort`) VALUES ('%s','%s','%s')",
                        array(
@@ -59,11 +63,10 @@ if (isFormSent('add')) {
                                postRequestElement('visible'),
                                bigintval(postRequestElement('parent') + 1)
                        ), __FILE__, __LINE__);
+
+               // Category has been added
                $content = '{--CATEGORY_ADDED--}';
-       } else {
-               // Category does already exists
-               $content = '<span class="bad">{--CATEGORY_ALREADY_EXISTS--}</span>';
-       }
+       } // END - if
 
        // Free memory
        sqlFreeResult($result);
@@ -145,8 +148,17 @@ if (isFormSent('add')) {
        $CATS = '';
 
        // Load all categories
-       $result = sqlQuery("SELECT `id`, `cat`, `visible`, `sort` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__);
-       if (!ifSqlHasZeroNums($result)) {
+       $result = sqlQuery("SELECT
+       `id`,
+       `cat`,
+       `visible`,
+       `sort`
+FROM
+       `{?_MYSQL_PREFIX?}_cats`
+ORDER BY
+       `sort` ASC", __FILE__, __LINE__);
+
+       if (!ifSqlHasZeroNumRows($result)) {
                // Init variables
                $OUT = '';