Thanks Burrito and sorry for not giving enough information.
Basically I have a dropdown select box and I don’t simply want the first item in the database to be shown in the list. I want it to be ‘Search All’ at the top of the list so that if somebody chooses to search the entire database rather than making a selection they will be able to.
You can see an example of my problem here
http://www.irishmusicteachers.ie The first item on both of these select boxes are ‘location’ and ‘instrument’ and I want for example to be able to ‘search all’ of either so for example I’d like to be able to select Dublin 25 and ‘Instrument’ to be ‘Search all’ and visa versa.
This is a snip of the code that I’m using.
Thanks very much for your time.
Brian
Code: Select all
<?PHP echo "<select name='Counties_IDPK' id='Counties_IDPK'>\n";
while($dbRow = mysql_fetch_array($rstSearchLocations)){
echo "<option value='"
. $dbRow["Counties_IDPK"]
. "'>"
. $dbRow["Counties_Name"]
."</option>\n";
} echo "</select>\n";
?>
Choose County</td>
</tr>
<tr>
<td><?PHP echo "<select name='Instruments_IDPK' id='Instruments_IDPK'>\n";
while($dbRow = mysql_fetch_array($rstSearch)){
echo "<option value='"
. $dbRow["Instruments_IDPK"]
. "'>"
. $dbRow["Instruments_Name"]
."</option>\n";
} echo "</select>\n";
?>
Choose Instrument or subject
Result page
Code: Select all
mysql_select_db($database_imtdatabase, $imtdatabase);
$query_rstResults = 'SELECT * FROM teachers,inst_teach,locations,instruments
WHERE teachers.contents_IDPK = inst_teach.teacher_IDFK
AND inst_teach.instrument_IDFK = instruments.instruments_IDPK
AND teachers.counties_IDFK = locations.counties_IDPK';
//If "both" is selected, the filter won't be used.
//If "school" is selected, the clause should read: AND Teachers.TeachTypes_ID IN (1,3)
//If "private" is selected, the clause should read: AND Teachers.TeachTypes_ID IN (2,3)
if ($_POST['School'] != '3') {
$query_rstResults .= ' AND teachers.teachtypes IN (' .$_POST['School'].',3)';
}
if (isset($_POST['Counties_IDPK'])) {
$query_rstResults .= ' AND locations.counties_IDPK = ' . $_POST['Counties_IDPK'];
}
if (isset($_POST['Instruments_IDPK'])) {
$query_rstResults .= ' AND instruments.instruments_IDPK = ' .$_POST['Instruments_IDPK'];
}