Functions: Enhance html_select_other() function.

This commit is contained in:
fusionate 2023-06-09 17:28:56 +00:00
parent e016d3d39c
commit 09ba7069dc
No known key found for this signature in database
1 changed files with 4 additions and 2 deletions

View File

@ -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 .= "<option value='Other'>Other</option>\n";
$html .= "<option value='' disabled='disabled'></option>\n";
$html .= "<option value='Other'>".$label_other."</option>\n";
$html .= "</select>\n";
$html .= "</td>\n";
$html .= "<td id=\"cell".$field_name."2\" width='5'>\n";