PHP帮助下拉列表与数据库值 [英] PHP help on dropdown list with database value

查看:99
本文介绍了PHP帮助下拉列表与数据库值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我在php中开发了一个项目,其中有两个表作为city(city_id,city_name)和hotel(hotel_id,city_id,hotel_name) 。 php页面包含两个下拉列表,其中第一个下拉列表包含列表城市,第二个下拉列表包含所选城市中的酒店(从第一个下拉列表中)

请帮我这个project。

解决方案

首先,获取城市的价值。选项的值应为城市ID。然后在hotel表中查询city_id的数据库,然后返回结果。例如



  


cityId =


_POST [' city']; // 从下拉列表中获取城市ID


Hello ,

I am developing one project in php in which there are two tables as city(city_id, city_name) and hotel(hotel_id, city_id, hotel_name). The php page contains two drop down list in which 1st drop down list contains the list cities and 2nd drop down list contains the hotels in the selected city(from 1st drop down list)
Please help me for this project.

解决方案

Firstly, get the value of the city. The value of the option should be the city ID. Then query the data base for the city_id in the hotel table, then return the results. E.g.


cityId =


_POST['city']; // Get the city id from the drop down


这篇关于PHP帮助下拉列表与数据库值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆