I have a database of, let's say, houses, and each house is, obviously, in a particular location. some locations contain more than one house. what i want to do is make a select box with all the locations in it as options.
here is the code i am using for the function. it returns the html code for the select box:
db_connect();
$data = db_query("SELECT * FROM houses");
$column_count = mysql_num_fields($data);
$code = '';
$code = $code . "<select name='location'>";
while ($row = mysql_fetch_row($data))
{
$code = $code . "<option>$row[2]</option>";
}
$code = $code . "</select>";
return $code;
$row[2] contains the location. the problem here is i get duplicates when there is more than 1 house in a particular location.
could anyone help me sort this out?