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);?>