function user_gender($string) { $return_string = "\n <input type=\"radio\" name=\"gender\" value=\"m\" " . is_checked_option("m", $string) . "> " . translate("male") . " \n <input type=\"radio\" name=\"gender\" value=\"f\" " . is_checked_option("f", $string) . "> " . translate("female") . " \n "; return $return_string; }
function enum_values_to_options($table, $field, $select_name, $posted, $rowed, $add_null, $o_type, $add_onchange_submit = false) { $query = "SHOW COLUMNS FROM `" . DBT_PREFIX . str_replace("`", "", $table) . "` LIKE '" . $field . "'"; sql_select($query, $results); settype($options, "string"); while ($line = mysql_fetch_array($results)) { $open = strpos($line['Type'], '('); $close = strrpos($line['Type'], ')'); // check if there are a string with () and if it conttains "enum" string at first if (!$open || !$close || !preg_match("#^enum#", $line['Type'])) { return FALSE; } $options_array = substr($line['Type'], $open + 2, $close - $open - 3); $options_array = explode("','", $options_array); sort($options_array); $available_value = available_posted_rowed($posted, $rowed); if (count($options_array) > 1) { if ($add_null == 1) { $options = "\n<option value=\"\">" . ucfirst(translate("select")) . "</option>"; $selected_value = $available_value; } else { $selected_value = $available_value ? $available_value : $line['Default']; } switch ($o_type) { /////// YES - NO case 'yn': foreach ($options_array as $key => $val) { $options .= "\n<option value=\"" . $val . "\" " . is_selected_option($val, $selected_value); if ($val == 0) { $options .= " style=\"background-color:#CC0000; font-weight: bold; color:#FFFFFF; \">" . translate("no"); } else { $options .= " style=\"background-color:#399D2F; font-weight: bold; color:#FFFFFF; \">" . translate("yes"); } $options .= "</option>"; } //end foreach return "\n<select name=\"" . $select_name . "\">" . $options . "\n</select>"; break; /////// ONLINE STATUS /////// ONLINE STATUS case 'o_status': foreach ($options_array as $key => $val) { $options .= "\n<option value=\"" . $val . "\" " . is_selected_option($val, $selected_value); if ($val == 0) { $options .= " style=\"background-color:#CC0000; font-weight: bold; color:#FFFFFF; \">" . translate("offline"); } else { $options .= " style=\"background-color:#399D2F; font-weight: bold; color:#FFFFFF; \">" . translate("online"); } $options .= "</option>"; } //end foreach return "\n<select name=\"" . $select_name . "\">" . $options . "\n</select>"; break; /////// RADIO /////// RADIO case 'radio': foreach ($options_array as $key => $val) { $options .= "<input type=\"radio\" name=\"" . $select_name . "\" value=\"" . $val . "\" " . is_checked_option($val, $selected_value) . "><" . ($selected_value == $val ? "strong class=\"red\"" : "span") . "> " . (!is_numeric($val) ? translate($val) : $val) . " </" . ($selected_value == $val ? "strong" : "span") . "><br>"; } //end foreach return "\n" . $options; break; /////// SELECT /////// SELECT default: foreach ($options_array as $key => $val) { $options .= "\n<option value=\"" . $val . "\" " . is_selected_option($val, $selected_value); if (!is_numeric($val)) { $options .= " >" . translate($val); } else { $options .= " >" . $val; } $options .= "</option>"; } //end foreach return "\n<select name=\"" . $select_name . "\" " . ($add_onchange_submit === true ? "onChange=\"submit();\"" : "") . ">" . $options . "\n</select>"; break; } $options = ""; } //end if($count) } //end while }