上面是误操作
关于分类递归的问题:mysql数据库表字段:
cid pcid cid_list
1 0 0,1
2 0 0,2
3 1 0,1,3
4 2 0,2,4
5 4 0,2,4,5怎样通过递归或都它的方法组合成cid_list字串
关于分类递归的问题:mysql数据库表字段:
cid pcid cid_list
1 0 0,1
2 0 0,2
3 1 0,1,3
4 2 0,2,4
5 4 0,2,4,5怎样通过递归或都它的方法组合成cid_list字串
global $stack;
$sql = "select pcid,cid from class where cid=".$cid;
$result = $db->sql_query($sql);
if (empty($stack)) {
$stack[] = $cid;
}
if (0==$db->sql_numrows($result)){
return false;
}else {
$rows = $db->sql_fetchrow($result);
$stack[] = $rows['pcid'];
getParentId($rows[pcid]);
}
return $stack;}