我有一个控制器函数,它有两个result_sets,一个是row_array()的result_set,第二个是来自result_array()的result_set,如下所示。
public function show_images($folderid)
{
$this->load->model('footer_model');
$data['footer'] = $this->footer_model->footer_list(); //result_set from row_array
$this->load->model('gallery_model');
$data['image_info'] = $this->gallery_model->get_allimages($folderid); //result_set from result_array
//print_r($data); exit();
$this->load->view('gallery/gallery_slides',$data);
}
两个结果集被传递给视图,我很困惑如何检索它。有没有办法检索它。我应该如何通过foreach
或通过其他方式在视图文件中执行此操作?
简单来说,以下是传递给视图的结果:
Array (
[footer] =>
Array (
[footer_id] => 1
[address1] => Wanderer,'The Refugee',
[address2] => XYX Compound, Observatory Road
[place] => Kodaikanal
[phone_no] => 2341929
[copyright_link] => www.megatrend.co.in
[email] => dbarunkumart@yahoo.co.in
)
[image_info] =>
Array (
[0] =>
Array (
[file_name] => DSC00081.JPG
[folder_name] => foldername )
[1] =>
Array (
[file_name] => DSC00082.JPG
[folder_name] => foldername )
)
)
答案 0 :(得分:3)
正如@Dinesh所提到的,您可以直接访问$footer
并循环访问$image_info
。
您视图中$footer
的示例:
<footer>
<?= $footer['address1'] ?>
<?= $footer['address2'] ?>
</footer>
您视图中$image_info
的示例
<footer>
<?php foreach($image_info as $img) { ?>
<img src="YOUR_PATH/<?= $img['file_name']; ?>"/>
<?php } ?>
</footer>