$cp_nav=array();
$db->Query('cpclass1','select * from #@__type where parent=2 ORDER BY `ORDER` ,`ID` ');
while($row1 = $db->GetArray('cpclass1')){
$db->Query('cpclass2',"select * from #@__type where parent='$row1[id]' ORDER BY `ORDER` ,`ID` LIMIT 5");
while($row2 = $db->GetArray('cpclass2')){
$cp2[]=$row2;
$db->Query('cpclass3',"select * from #@__type where parent='$row2[id]' ORDER BY `ORDER` ,`ID` LIMIT 5");
while($row3 = $db->GetArray('cpclass3')){
$cp3[]=$row3;
}
}
$row2['cp3']=$cp3;
$row1['cp2']=$cp2;
$cp_nav[]=$row1;
}
$qf->assign('cp_nav',$cp_nav);
猜测:
你的SQL执行后的句柄或结果被保存在一个变量里,那么第二次执行的时候,把第一次的句柄给覆盖掉了!
这个是三层循环。1级-2级-3级。子级别的parent对应的是父级别的id,1级的parent是2.
现在1级和2级的东西都取出来了。3级的东西取不出来。