Forum Moderators: coopster
<select name=\"search_city\">";
$conn=db_connect();// your DB conn function or hard coded DB conn script
// note: $state was passed via a POST as such it calls for mysql_real_escape_string()
$query = "SELECT DISTINCT `city` FROM my_table WHERE `state` = '".mysql_real_escape_string($state)."' ORDER BY `city` ASC";
$result= mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
// loop till all cities are gathered
// $i (for ittereation) will run untill $i <$num is no more correct
while ($i <$num)
{ // then build the options list
echo "<option>";
$search_city=mysql_result($result,$i,"city");
echo"$search_city";
$i++;
}
echo"</select>";
What about a php scripts that contains the drop-down list. Each time the page loads, it calls the script to load the drop-down. This way, I do not have to populate a database....
Thanks...