Details on the effect of the second-level linkage menu implemented by php + mysql _ php skills

Source: Internet
Author: User
This article mainly introduces the level-2 linkage menu effect of php + mysql, involving the connection and query of php operations on mysql and DOM node operations combined with javascript to achieve level-2 linkage menu effect, the corresponding SQL statements of the mysql database are also included at the end. if you need them, you can refer to the examples in this article to describe the two-level linkage menu effects implemented by php + mysql. We will share this with you for your reference. The details are as follows:

 
 Generate a College professional cascade drop-down menu test<? ///*************************************: Php + mysql + javascript implements the secondary cascade drop-down box of the school major ** database: database name (dms), Data Table (colleges, majors) ** field in table colleges: college_id (id number) fields in the majors table of "school name" **: major_id (id number), college_id (school ID), name (school name) ** version 1.0: wu yaowen ************************************** * ******** // ************************ select a database connection ******* * ******* $ link = mysql_connect ("localhost ", "ro Ot "," 123456 ") or die (" cocould not connect :". mysql_error (); mysql_select_db ("dms") or die ("cocould not select database "); ***************** * $ queryCol = "select * from colleges order by college_id "; mysql_query ("set names 'gb2312 '"); $ result1 = mysql_query ($ queryCol) or die ("Query failed :". mysql_error (); $ colleges = array (); while ($ row1 = mysql_fetch_array ($ result1 )){ $ Colleges [] = $ row1;} // print_r ($ forum_data); mysql_free_result ($ result1 ); // *************** obtain professional information *************** $ queryMaj = "select * from majors order by college_id desc "; mysql_query ("set names 'gb2312 '"); if (! ($ Result2 = mysql_query ($ queryMaj) {die ('could not query t_city list');} $ majors = array (); while ($ row2 = mysql_fetch_array ($ result2) {$ majors [] = $ row2;} mysql_free_result ($ result2);?>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.