0

I have 6 values (room types) in a dropdown list which I have retrieved from the database. I want to display a div according to the selected value in the dropdown list without clicking the submit button.

My code to retrieve the value from database is:

<?php
$sql = "SELECT roomtype_des FROM roomtype";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
echo "<option value='" . $row['roomtype_des'] . "' >" .$row['roomtype_des'] 
."</option>";
?>

the only problem is I don't know how to display a div according to the selected value.

NOTE that I have 6 different divs of the 6 selected value.

Jaskaran Singh
  • 1,818
  • 21
  • 33
David
  • 1
  • 4
  • 2
    Because you tagged jquery, I think you understand that you cannot do this with PHP. May I suggest reading this question? https://stackoverflow.com/questions/20943454/create-div-based-on-selected-drop-down-value – IsThisJavascript Dec 19 '17 at 10:22
  • 1
    Next time please google your title. It is not just a FAQ it is a VFAQ – mplungjan Dec 19 '17 at 10:24
  • the answers are not related to the dropdown list based on database mysql – David Dec 19 '17 at 10:31
  • Regardless of how you get the data David, Javascript is required. Php and MySQL have little to do with your issue apart from that's how you are generating the output. The answers you seek are in those questions – IsThisJavascript Dec 19 '17 at 10:33

0 Answers0