转载本站文章请注明,作者:jean
本文连接http://www.zhangyiqun.net/1203.html
我有一个遍历数据库返回的需求,代码如下
//此处获取的值是一个数组 $this->load->database(); $query = $this->db->query("select ID,title from jscodebox where author='jean'"); if ($query->num_rows>0){ $data['filelist'] = $query; } $this->load->view('box',$data); //现在我把这个数组在视图里显示。这里需要注意的是在CodeIgniter中遍历数据库的动作 <ul id="mycodelist" style="list-style-type:none;"> <?php foreach($filelist->result() as $item):?> <li><?php echo $item->title;?></li> <?php endforeach;?> </ul> |
