I have some code that populates a drop down menu but I have a few questions regarding it..
<form action="results.php" method="POST">
<?php
include "config.php";
$db = mysql_connect ($Host, $User, $Password);
mysql_select_db ($DBName) or die ("Cannot connect to database");
/ We have now connected, unless you got an error message /
function select_menu_areas( $nam )
{
$sel = '<select name="' . $nam . '">';
$sel .= '<option selected>Choose An Area</option>';
$qry = mysql_query( "SELECT DISTINCT id, areas FROM houses" );
while ( $dat = mysql_fetch_array( $qry ) ) {
$sel .= '<option value="' . $dat['id'] . '">' . $dat['areas'] . '</option>' . "\n";
}
$sel .= '</select>';
return( $sel );
}
?>
<strong><font size="2" face="Arial, Helvetica, sans-serif">Select from the menu</font></strong><br>
<br>
<?php
echo select_menu_areas( 'cities' );
?>
<INPUT TYPE="HIDDEN" NAME="id">
<input type="Submit" name="Submit" value="Submit">
</form>
1/ The DISTINCT command isn't working - I'm getting all entries being listed in the drop down, including duplicates.
2/ I would like to create a results page but have got stuck! So would like some help producing one.
3/ Can I amend the code so I could have three drop down menus in total (one for areas, one for towns and one for zipcodes).
4/ If I have three drop downs I would need to amend the code so that if 'Choose an Area' was the selection all areas would be listed and the same with towns and zipcodes...
I have got a headache - simple explanations/replies would be much appreciated!