简体   繁体   English

我可以使用下拉菜单从数据库中检索值吗

[英]Can I use DropDown menus to retrieve values from a database

Below is the "Room" table in the database: 下面是数据库中的“房间”表:

   Room          Building            Capacity
    CW5/10        Canalside West        50
    CW4/09        Canalside West        40
    CW2/08        Canalside West        40
    CW4/10        Canalside West        25
    CE1/03        Canalside East        40

What I want to do if it is possible is to create 2 dropdown menus. 我想做的是创建2个下拉菜单。 One dropdown menu is for the "Building" field where it will displays all the buildings as individual values in the dropdown list and then in the second drop down menu, it will display the list of rooms which is 第一个下拉菜单用于“建筑物”字段,它将在下拉列表中将所有建筑物显示为单独的值,然后在第二个下拉菜单中,将显示房间列表。

You can adapt this AJAX example to do what you need. 您可以修改此AJAX示例以完成所需的操作。

http://www.w3schools.com/php/php_ajax_database.asp http://www.w3schools.com/php/php_ajax_database.asp

Just adapt the getuser.php file to show another drop down list rather than the table. 只需修改getuser.php文件即可显示另一个下拉列表,而不是表格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM