Home > Backend Development > PHP Tutorial > PHP从数据库获取的下拉树

PHP从数据库获取的下拉树

WBOY
Release: 2016-06-23 13:48:06
Original
1068 people have browsed it

include "config.php";
include "mysql.php";
$db = new Mysql('test'); //几个简单的类,不用列出来大家也看得懂。就是实例化一个数据库连接而已。
function RootMenu ($PID,$n){
global $arr,$db;
$sql = "select * from menu where `PID` =$PID";
$result = $db->query($sql);
while ($i=$db->fetch_array($result)){
   $i["TITLE"] =str_repeat('--',$n).$i["TITLE"];
   $arr[] =$i;
   RootMenu($i["ID"],($n+4));

}
return $arr;

$arr = RootMenu(0,0);
?>


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