0

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>";

?>
2
  • what is the problem? you dont get values in dropdown? Commented Mar 27, 2012 at 10:32
  • It seems this is a duplicate query: stackoverflow.com/questions/9848079/… Commented Mar 27, 2012 at 10:33

2 Answers 2

1

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>";
Sign up to request clarification or add additional context in comments.

Comments

1
echo "<select name='property'><option value=''>Please Choose Availability</option>";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.