我现在的代码是这样的
<?php
$this->db->where('pid','0');
$this->db->limit(5);
$this->db->order_by('id','asc');
$channel_data1 = $this->db->get('channel')->result();
foreach($channel_data1 as $row1):
?>
<div>
<h2><?php echo $row2->name;?></h2>
<ul>
<?php
$this->db->where('pid',$row1->id);
$this->db->order_by('id','asc');
$this->db->limit(10);
$channel_data2 = $this->db->get('channel')->result();
foreach($channel_data2 as $row2):
?>
<li><a href="<?php echo $row2->url;?>"><?php echo $row2->name;?></a></li>
<?php
endforeach;
?>
</ul>
</div>
<?php
endforeach;
?>