HI - I am dynamically populating a drop down form list from the table 'hotels', and the 'est_town' column. It is supposed to only list each town once, but several towns appear multiple times. Am I using the DISTINCT command correctly and if so, what can i do to stop multiple appearances of towns?
$query_hotels_select = "SELECT DISTINCT est_town FROM hotels ORDER BY est_town ASC";
$hotels_select = mysql_query($query_hotels_select, $contractors) or die(mysql_error());
$row_hotels_select = mysql_fetch_assoc($hotels_select);
$totalRows_hotels_select = mysql_num_rows($hotels_select);
FORM BIT
<select name="digs" id="digs">
<?php
do {
?>
<option value="<?php echo $row_hotels_select['est_town']?>"<?php if (!(strcmp($row_hotels_select['est_town'], $row_hotels_select['est_town']))) {echo "selected=\"selected\"";} ?>><?php echo ucwords(strtolower($row_hotels_select['est_town']))?></option>
<?php
} while ($row_hotels_select = mysql_fetch_assoc($hotels_select));
$rows = mysql_num_rows($hotels_select);
if($rows > 0) {
mysql_data_seek($hotels_select, 0);
$row_hotels_select = mysql_fetch_assoc($hotels_select);
}
?>
[code=html] </select>[/code]