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

PHP从数据库获取的下拉树

WBOY
WBOYOriginal
2016-06-23 13:48:061069browse

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


Statement:
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