commit | author | age
|
e2b48d
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* 商品分类 |
|
5 |
*/ |
|
6 |
define('IN_ECS', true); |
|
7 |
require('includes/init.php'); |
|
8 |
$result=array(); |
|
9 |
$result2=array(); |
|
10 |
$res = $db -> getAll("SELECT cat_id,cat_name FROM ".$ecs->table('category')." WHERE parent_id='0' and is_show='1' order by sort_order asc"); |
|
11 |
foreach ($res as $key=>$val) |
|
12 |
{ |
|
13 |
$parent_id=$val['cat_id']; |
|
14 |
$result2['cat_id']=$val['cat_id']; |
|
15 |
$result2['cat_name']=$val['cat_name']; |
|
16 |
$rows = $db -> getAll("SELECT cat_id,cat_name FROM ".$ecs->table('category')." WHERE parent_id='$parent_id' and is_show='1' order by sort_order asc"); |
|
17 |
for($i=0;$i<count($rows);$i++){ |
|
18 |
$children_id=$rows[$i]['cat_id']; |
|
19 |
$rows2 = $db -> getAll("SELECT cat_id,cat_name FROM ".$ecs->table('category')." WHERE parent_id='$children_id' and is_show='1' order by sort_order asc"); |
|
20 |
$rows[$i]['children']=$rows2; |
|
21 |
} |
|
22 |
$result2['list']=$rows; |
|
23 |
$result[]=$result2; |
|
24 |
} |
|
25 |
|
|
26 |
print_r(json_encode($result)); |
|
27 |
|
|
28 |
?> |