I would usually try to figure little programming problems out myself but this is too complicated for me.
I'm using Drupal CMS with some fairly customised scripts. One of which looks like this:
<?php
// These are the fields we want to show up in the basic search.
$profileFields = "\"profile_employtype\", \"profile_employsector\"";
// This is a list of fields that we do not want to show in the search option.
// IE: Things the members writes about them self.
$profileHideFields = "\"profile_website\", \"profile_addressline1\", \"profile_addressline2\"";
$result = db_query(
'SELECT *
FROM {profile_fields}
WHERE name NOT IN (' . $profileHideFields . ')
AND name IN (' . $profileFields . ')
ORDER BY fid'
);
$output .= "\n";
$output='<form action="profile" method="GET">';
$output .= "\n";
$output .= '<table>';
$output .= "\n";
while ($field = db_fetch_object($result)) {
$output .= '<tr>';
$output .= "\n";
$output .= '<td>';
$output .= "\n";
$output .= t($field->title) . ' ' ;
$output .= '</td>';
$output .= "\n";
$output .= '<td>';
$output .= "\n";
switch($field->type) {
case 'selection':
$output .= "<select name='" . $field->name . "'>";
$options = $field->required ? array() : array('--');
$lines = split("[,\n\r]", $field->options);
foreach ($lines as $line) {
if ($line = trim($line)) {
$output .= "\n";
$output .= "<option value='" . $line . "'>$line</option>";
}
}
$output .= "\n";
$output .= '</select>';
break;
case 'textfield':
$output .= "\n";
$output .= '<input type="textfield" name="$field->name">';
break;
}
$output .= "\n";
$output .= '</td>';
$output .= "\n";
$output .= '</tr>';
}
$output .= '<tr>';
$output .= "\n";
$output .= '<td colspan="2" align="center"><input type="submit" value="Basic Search" name="search"></td>';
$output .= "\n";
$output .= '</tr>';
$output .= '</table>';
$output .= '</form>';
$output .= "\n";
return $output;
?>
It generates HTML with two dropdown selection boxes 'employment type' and 'employment sector', which the user selects and then clicks on a radio button 'Basic Search' which takes him/her to the results page. It all works fine EXCEPT:
I need the dropdown menu's to have the usual '--' option for 'no selection' and for this to be set as the default. So that it is possible to search by EITHER employment type or sector (or neither, theoretically) and the other option would remain unspecified.
I'm guessing this has to do with the line:
$options = $field->required ? array() : array('--');
but I have no idea how that functions, and it may even be inscrutable to you because of Drupal whatnot.
I used to program in BBC Basic but things have got more sophisticated since 1989.
Thanks in advance