Reputation: 21
I have a mysql generate dropdown list..need to add in a pre selected option such as "Please Choose Availability". Not too sure how to do this as the drop down content is generated from a database
<?php
$sql = "SELECT DISTINCT availability FROM properties";
$result = mysql_query($sql);
echo "<select name='property'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='". $row['availability']. "'>" . $row['availability'] ."</option>";
}
echo "</select>";
?>
Upvotes: 0
Views: 1576
Reputation: 9034
echo "<select name='property'><option value=''>Please Choose Availability</option>";
Upvotes: 1
Reputation: 2561
if you want static first value for dropdown then you can do it like this.
echo "<select name='property'><option value=''>Please Choose Availability </option>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='". $row['availability']. "'>" . $row['availability'] ."</option>";
}
echo "</select>";
Upvotes: 1