]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Huge HTML/CSS rewrite (see forum)
[mailer.git] / inc / mysql-manager.php
index bc2ccddadf095d4718a0f10feb9815586c4324f9..27961f5f608adb5bd0c1fe4a82656cf63718cfec 100644 (file)
@@ -1644,22 +1644,29 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher
        $ret = '';
        if ($table == '/ARRAY/') {
                // Selection from array
-               if (is_array($id) && is_array($name) && count($id) == count($name)) {
+               if ((is_array($id)) && (is_array($name)) && (count($id)) == (count($name))) {
                        // Both are arrays
                        foreach ($id as $idx => $value) {
                                $ret .= '<option value="' . $value . '"';
                                if ($default == $value) $ret .= ' selected="selected"';
                                $ret .= '>' . $name[$idx] . '</option>';
                        } // END - foreach
-               } // END - if
+               } else {
+                       // Problem in request
+                       debug_report_bug('Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
+               }
        } else {
                // Data from database
-               $SPEC = ', '.$id;
+               $SPEC = ', `' . $id . '`';
                if (!empty($special)) $SPEC = ', ' . $special;
-               $ORDER = $name.$SPEC;
+               $ORDER = $name . $SPEC;
                if ($table == 'country') $ORDER = $special;
-               $result = SQL_QUERY_ESC("SELECT %s, %s".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$where." ORDER BY %s",
-               array($id, $ORDER, $table, $name), __FUNCTION__, __LINE__);
+
+               // Query the database
+               $result = SQL_QUERY_ESC("SELECT `%s`, `%s`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$where." ORDER BY %s",
+                       array($id, $ORDER, $table, $name), __FUNCTION__, __LINE__);
+
+               // Do we have rows?
                if (SQL_NUMROWS($result) > 0) {
                        // Found data so add them as OPTION lines: $id is the value and $name is the "name" of the option
                        // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()