php+mysql+js implements tree menu code_PHP tutorial

WBOY
Release: 2016-07-13 10:57:47
Original
1193 people have browsed it

php+mysql+js implements tree menu code This is a php+mysql database that reads the content of the database and regenerates it into a tree model menu controlled by js

php tutorial+mysql tutorial+web page special effects to implement tree menu code
This is a php+mysql database tutorial that reads the contents of the database and regenerates the tree model menu controlled by js
*/
?>




Category tree



$globals["id"] =1; //The id number used to track the drop-down menu
$layer=1; //The level used to track the current menu
//Connect to database
$con=mysql_connect("localhost","root","123456");
mysql_select_db("demo");

//Extract the first-level menu
$sql="select * from think_news where `f_id`=0";
$result=mysql_query($sql,$con);
//If the first-level menu exists, display the start menu
if(mysql_num_rows($result)>0) showtreemenu($con,$result,$id);
function showtreemenu($con,$result,$layer)
{
//Get the number of menu items that need to be displayed
$numrows=mysql_num_rows($result);
//Start to display the menu, each submenu is represented by a table
echo "

";
for($rows=0;$rows<$numrows;$rows++)
{
//Import the contents of the current menu item into the array
$menu=mysql_fetch_array($result);
//Extract the submenu record set of menu items
$sql="select * from think_news where f_id=$menu[id]";
$result_sub=mysql_query($sql,$con);
echo "";
//If the menu item has a submenu, add the javascript onclick statement
If(mysql_num_rows($result_sub)>0)
{
echo "";
echo "";
echo "";
//If the menu item has a submenu, display the submenu
If(mysql_num_rows($result_sub)>0)
{
//Specify the id and style of the submenu to correspond to the onclick statement
echo "";
echo "";
echo "";
}
//Submenu processing is completed, return to the previous level of recursion, and reduce the series by 1
$layer--;
}
echo "
";
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632057.htmlTechArticlephp+mysql+js implementation of tree menu code This is a database reading method by php+mysql database The content regeneration tree model menu is controlled by js. PHP tutorial + mysql tutorial + web page special effects realize tree-shaped menu...
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