无限分类

#1 homexigua

require('Category.class.php');//导入Category.class.php类

//测试数据

$data[]=array('cat_id'=>1,'pid'=>0,'name'=>'中国');

$data[]=array('cat_id'=>2,'pid'=>0,'name'=>'美国');

$data[]=array('cat_id'=>3,'pid'=>0,'name'=>'韩国');

$data[]=array('cat_id'=>4,'pid'=>1,'name'=>'北京');

$data[]=array('cat_id'=>5,'pid'=>1,'name'=>'上海');

$data[]=array('cat_id'=>6,'pid'=>1,'name'=>'广西');

$data[]=array('cat_id'=>7,'pid'=>6,'name'=>'桂林');

$data[]=array('cat_id'=>8,'pid'=>6,'name'=>'南宁');

$data[]=array('cat_id'=>9,'pid'=>6,'name'=>'柳州');

$data[]=array('cat_id'=>10,'pid'=>2,'name'=>'纽约');

$data[]=array('cat_id'=>11,'pid'=>2,'name'=>'华盛顿');

$data[]=array('cat_id'=>12,'pid'=>3,'name'=>'首尔');



$cat=new Category(array('cat_id','pid','name','cname'));

$s=$cat->getTree($data);//获取分类数据树结构

//$s=$cat->getTree($data,1);获取pid=1所有子类数据树结构

foreach($s as $vo)

{

echo $vo['cname'].'
';

}
*/
Category.zip

2011-12-01 14:32:14

#2 lhabc

早放出来,我就不用折腾那么久了,呵呵

2011-12-10 10:07:54

#3 a752711024

支持,看过,用过

2011-12-12 10:09:13