Set up drop-down menu in excel and implement multi-level tree menu with PHP

WBOY
Release: 2016-07-29 08:34:11
Original
1597 people have browsed it

//Tree directory structure template program
//Menu directory library field description:
//menu_id menu item id
//menu menu name
//menu_grade menu level 1 is the main menu and 2 is the secondary menu. .......
//menu_superior menu id number
function my_menu($menu_content,$i,$menu_grade_temp,$menu_superior_temp)
{ global $PHP_SELF;
$temp1=$menu_grade_temp+1;
$menu_superior_temp_array=split("/",$menu_superior_temp);
for ($t=0;$t<$i;$t++)
{
$menu_array=split("/",$menu_content[$t]);
If(($menu_array[2]==$menu_grade_temp)&&($menu_array[3]==$menu_superior_temp_array[$menu_grade_temp-1]))
                                              $p++){echo " ";}                     $temp3=$menu_superior_temp_array;                          If ($menu_array[ 0]==$menu_superior_temp_array[$temp1-1])                                                                                                                                                         $temp5           ("/",$temp3);
echo "$menu_array[1]
";
my_menu($menu_content,$i . temp3);                                                                           echo "$menu_array[1]
";
// Connect to MySql database
$ db_host="localhost";
$db_user="dkj";
$db_password="123";
$db_name="test";
mysql_connect($db_host,$db_user,$db_password);
mysql_select_d b($db_name);
//Get data from the database
$query_string="select * from menu order by menu_grade";
$db_data=mysql_query($query_string);
//Perform initialization for the first time
if ($menu_grade_temp=="")
{
$menu_superior_temp=0;
}
//Read all the information into the array and count the number of arrays
$i=0;
while (list($menu_id,$menu,$menu_grade,$menu_superior)=mysql_fetch_row($db_data))
{
$ menu_content[$i]=$menu_id."/".$menu."/".$menu_grade."/".$menu_superior;
$i++;
} my_menu($menu_content,$i,1,$menu_superior_temp) ;
/* Attached database structure and simulation data
# phpMyAdmin MySQL-Dump #
# Host: localhost Database: test
# ---------------------- ----------------------------------
#
# Data table structure 'menu'
# CREATE TABLE menu (
menu_id int(11) NOT NULL auto_increment,
menu varchar(20) NOT NULL,
menu_grade int(11) NOT NULL,
menu_superior int(11) NOT NULL,
UNIQUE menu_id (menu_id)
);
#
# Export the following database content 'menu'
#
INSERT INTO menu VALUES( '1', 'Computer', '1', '0');
INSERT INTO menu VALUES( '2', 'Programming', ' 2', '1');
INSERT INTO menu VALUES( '3', 'Network', '2', '1');
INSERT INTO menu VALUES( '4', 'PHP and MySql', '3' , '2');
INSERT INTO menu VALUES( '5', 'C language', '3', '2');
INSERT INTO menu VALUES( '6', 'Web page production', '3', ' 3');
INSERT INTO menu VALUES( '7', 'TCP, IP protocol', '3', '3');
INSERT INTO menu VALUES( '8', 'Mathematics', '1', '0 ');
INSERT INTO menu VALUES( '9', 'Advanced Mathematics', '2', '8');
INSERT INTO menu VALUES( '10', 'Linear Algebra', '3', '9') ;
INSERT INTO menu VALUES( '11', 'Discrete Mathematics', '3', '9');
INSERT INTO menu VALUES( '12', 'Elementary Mathematics', '2', '8');
INSERT INTO menu VALUES( '13', 'Literature', '1', '0');
INSERT INTO menu VALUES( '14', 'Chinese Literature', '2', '13');
INSERT INTO menu VALUES( '15', 'php', '4', '4');
INSERT INTO menu VALUES( '16', 'mysql', '4', '4');
*/
?>
The above introduces how to use PHP to implement multi-level tree menus in excel setting drop-down menus, including the content of excel setting drop-down menus. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template