The code example shows the implementation of the PHP level-2 linkage menu. For beginners, the PHP second-level linkage menu code example: scriptlanguageJavaScriptvaronecount; onecount0; subcatnewArray ();? Phpmysql_connect (localhost, charles, c for beginners,
PHP second-level linkage menu code example:
- < ScriptLanguage = "JavaScript">
- Var onecount;
- Onecount = 0;
- Subcat = new Array ();
- <? Php
- Mysql_connect ("localhost", "charles ",
"Charles ");
- Mysql_select_db ("_ crm ");
- $ SQL = "select * from site ";
- $ Result = mysql_query ($ SQL );
- $ Count = 0;
- While ($ res = mysql_fetch_row ($ result )){
- ?>
- Subcat [<? Php echo $ count?>] = New Array
("<? Php echo $ res [0]?>","<? Php echo
$ Res [2]?>","<? Php echo $ res [1]?>");
- <? Php
- $ Count ++;
- }
- Echo "onecount = $ count ;";
- ?>
- // Linkage function
- Function changelocation (locationid)
- {
- Document. myform. ctype. length = 0;
- Var locationidlocationid = locationid;
- Var I;
- For (I = 0; I< Onecount; I ++)
- {
- If (subcat [I] [2] = locationid)
- {
- // Var newnewOption1 = new Option (subcat [I]
[1], subcat [I] [0]);
- // Document. all. ctype. add (newOption1 );
- Document. myform. ctype. options [document.
Myform. ctype. length] = new Option (subcat
[I] [1], subcat [I] [0]);
- }
- }
- }
- </Script>
- < FormMethod = "post" name = "myform"
Action = "ru_query.php">
- < SelectName = "type" onChange = "changelocation (
Document. myform. type. options [document. myfo
Rm. type. selectedIndex]. value) "size =" 1">
- < OptionSelected value = "">Main</Option>
- <? Php
- $ SQL = "select * from entreprise ";
- $ Result = mysql_query ($ SQL );
- While ($ res = mysql_fetch_row ($ result )){
- ?>
- < OptionValue = "<? Php echo $ res [0];?> ">
- <? Php echo $ res [1];?> </Option>
- <? Php}?>
- </Select>
- < SelectName = "ctype">
- < OptionSelected value = "">Sub</Option>
- </Select>
- < InputType = "submit" name = "Submit" value = "search">
- </Form>
The above code is the specific implementation method of the PHP level-2 linkage menu.
Example code of the PHP second-level linkage menu: script language = JavaScript varonecount; onecount = 0; subcat = new Array ();? Php mysql_connect (localhost, charles, c...