$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()