PHP / mysql动态依赖下拉列表 [英] PHP/mysql dynamic dependent dropdown

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

问题描述

您好,

我需要为大学创建一个学生数据库。我创造它。现在我需要添加一个包含依赖下拉列表的表单。表格需要有3个下拉列表显示部门(部门),接下来需要显示所选部门相关的最后一个需要显示部分。我的数据库名称是department,我的表名是students.my表是

表`学生'的表结构

-



CREATE TABLE IF NOT NOT EXISTS`school`(

`id`int(11)NOT NULL AUTO_INCREMENT,

`name` varchar(200)NOT NULL,

`famame`varchar(200)NOT NULL,

`dept` varchar(200)NOT NULL,

`youn` int (200)NOT NULL,

`section`varchar(200)NOT NULL,

`contact`varchar(30)NOT NULL,

PRIMARY KEY(`id`)

)ENGINE = MyISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT = 46;



-

- 表'学生'的转储数据

-



INSERT INTO`school`(`id`,`name `,`faname`,`dept`,`year`,`section`,`contact`)VALUES

(43,'Vetri Kumar','Raja','BABL',4,' A','9500671384'),

(38,'Nandhini','Krishnan','BCA',3,'A','9965224881'),
(39,'Sakthi','Mahendhran','BABL',3,'B','8608769454'),

(44,'raji','raja ','BABL',4,'B','9874563210'),

(45,'Nithi','devraj','BCA',3,'A','9865230140') ;

Hello,
I need to create a student database to a college. i create it. Now i need to add a form which contains dependent dropdown list in it. That the form need to have 3 dropdown list on is show the dept(department) and next need to show the selected department related years the final one need to show the sections of selected year of department. my database name is department and my table name is students.my table is
Table structure for table `students`
--

CREATE TABLE IF NOT EXISTS `students` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`faname` varchar(200) NOT NULL,
`dept` varchar(200) NOT NULL,
`year` int(200) NOT NULL,
`section` varchar(200) NOT NULL,
`contact` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=46 ;

--
-- Dumping data for table `students`
--

INSERT INTO `students` (`id`, `name`, `faname`, `dept`, `year`, `section`, `contact`) VALUES
(43, 'Vetri Kumar', 'Raja', 'BABL', 4, 'A', '9500671384'),
(38, 'Nandhini', 'Krishnan', 'BCA', 3, 'A', '9965224881'),
(39, 'Sakthi', 'Mahendhran', 'BABL', 3, 'B', '8608769454'),
(44, 'raji', 'raja', 'BABL', 4, 'B', '9874563210'),
(45, 'Nithi', 'devraj', 'BCA', 3, 'A', '9865230140');

推荐答案

假设:php / MySQL暗示您很可能正在进行Web开发。



I建议您查看 AJAX - 这将允许您根据对其他部分的更改来更新表单的各个部分。



AJAX调用是javaScript,使用适当的代码调用.php文件(如更改的下拉选项中的值)。



Assumption: php/MySQL implies you're very likely doing web development.

I suggest you look into AJAX - which will allow you to update sections of your form based upon changes to other sections.

AJAX calls are in javaScript, which calls a .php file with the appropriate code (like the value from a changed dropdown selection).


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

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