PHP的下拉框categorycall列表 [英] php drop down box categorycall list

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

问题描述



我想创建2个选择框.选择的第一个框的选项将决定在第二个选择框中可见的选项.例如:

选择框A包含选项2010、2011、2012

选择框B包含根据电影发行年份而定的电影名称.

现在,当在框A中选择说选项2012时,仅显示发行日期在2012年的那些电影.

请帮助使用PHP/MySQL进行编码.


在此先谢谢您.

Hi,

I want to create 2 select boxes. The option of the first box chosen will decide the options visible in the second select box. For example:

Select box A contains options 2010, 2011, 2012

Select box B contains movies names according their release year.

Now when say option 2012 is selected in box A, only those movies which have their release year on 2012 are displayed.

Please help coding in PHP/MySQL.


Thanks in advance.

推荐答案

您需要一个带有WHERE子句的简单查询!

示例:
You need a simple query with a WHERE clause!

Example:
SELECT  
  movieNames
FROM
  Movies
WHERE
  movieYear = '2012'


您将必须传递movieYear作为参数,以查询其值等于选择的boxA选项的位置.将查询结果设置为此框B的数据源.


You will have to pass movieYear as a parameter to query where its value will be equal to boxA option selected. Set query result as a datasource of this boxB.


朋友,
这些提示可能会为您提供帮助.很抱歉,由于我尚未准备好代码,因此不会为您提供代码,因此创建代码确实需要时间.但我会给您一些提示,告诉您可以朝着成功的方向前进.

1.首先创建一个MySQL数据库,并可能创建两个表,一个表用于年份,另一个表用于影片名称或类似名称,您可以创建一个对您来说更合乎逻辑的表.

2.第二步是使用AJAX(是的,使用Javascripting),除非您计划每次用户从第一个选择框中选择Year时都重新加载页面.

3.第三步是创建AJAX脚本.创建一个函数,该函数将在onchange()事件上提交第一个选择框的值.

4.在php中创建一个没有任何html的页面.此页面将接收此数据(Selectbox1的值),并使用MYSQL查询对其进行处理,以获取将存储电影名称的数组的列表.使用以下代码作为示例回显此数据:
Hi Friend,
These tips may help you. I am sorry that I will not be providing you with codes since I have not one ready, and it really takes time to create one. But I will be giving you hints toward which you can move your way to reach the success.

1. First of all create a MySQL database and possibly create two tables, the one for the year and the another for film name or something like that, you are able to create one that seems more logical to you.

2. The second step is using AJAX (Yes, Javascripting) unless you have planned to reload the page everytime the user select an Year from the first select box.

3. The third step will be if you are going with creating an AJAX script. Create a function that will submit the Value of first selectbox on a onchange() event.

4. Create a page in php without any html inside it. This page will receive this data (the value of Selectbox1) and process it using MYSQL query to get a list of the array that will be storing the name of the Movies. Echo this data using this kind of code as example:
foreach(


dataarray as
dataarray as


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

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