+function build_select($name, $details)
+{
+ $ret = array();
+
+ $ret[] = '<div class="form">';
+ $ret[] = sprintf('<p class="title">%s</p>', $details['title']);
+ $ret[] = sprintf ('<select%s>', array_key_exists('onchange',$details)?sprintf(' onchange="%s"',$details['onchange']):'');
+ if (is_array($details['options']))
+ $options = $details['options'];
+ else
+ $options = query_db($details['options']);
+
+ if (array_key_exists('default',$details))
+ $ret[] = sprintf('<option value="">%s</option>', $details['default']);
+
+ foreach ($options as $row) {
+ $selected = array_key_exists('selected',$details) && $details['selected'] == $row['id'] ? true : false;
+ $ret[] = sprintf('<option value="%s"%s>%s</option>', $row['id'], $selected?' selected':'',$row['text']);
+ }
+
+ $ret[] = '</select>';
+ $ret[] = '</div>';
+
+ return $ret;
+}
+