From 09ba7069dc750b82675b2043357f9790432c847a Mon Sep 17 00:00:00 2001 From: fusionate Date: Fri, 9 Jun 2023 17:28:56 +0000 Subject: [PATCH] Functions: Enhance html_select_other() function. --- resources/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index 9e6600abc5..c45585cc26 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -343,7 +343,7 @@ } if (!function_exists('html_select_other')) { - function html_select_other($table_name, $field_name, $sql_where_optional, $field_current_value) { + function html_select_other($table_name, $field_name, $sql_where_optional, $field_current_value, $sql_order_by = null, $label_other = 'Other...') { //html select other: build a select box from distinct items in db with option for other global $domain_uuid; $table_name = preg_replace("#[^a-zA-Z0-9_]#", "", $table_name); @@ -358,6 +358,7 @@ $sql = "select distinct(".$field_name.") as ".$field_name." "; $sql .= "from ".$table_name." ".$sql_where_optional." "; + $sql .= "order by ".(!empty($sql_order_by) ? $sql_order_by : $field_name.' asc'); $database = new database; $result = $database->select($sql, null, 'all'); if (is_array($result) && @sizeof($result) != 0) { @@ -369,7 +370,8 @@ } unset($sql, $result, $field); - $html .= "\n"; + $html .= "\n"; + $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n";