我试图通过控制器和模型从数据库中获取横幅图像。
我的控制器:
class Home extends CI_Controller {
    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model('home_model');
    }
    public function index() {
        $data = array();
        $data['bannerInfo'] = $this->home_model->selectBanner($banner_id);
        $data['result'] = $this->home_model->selectCategory($category_id);
        $data['banner'] = $this->load->view('banner',$data, TRUE);
        $data['maincontent'] = $this->load->view('home_message',$data,TRUE);
        $data['title'] = 'NZ Furniture Products ';
        $data['keywords'] = 'furniture bangladesh';
        $this->load->view('home', $data);
   }
我的模型课:
class Home_Model extends CI_Model {
    // put your code here
    public function selectCategory($category_id)
    {
        $this->db->select('*');
        $this->db->from('tbl_category');
        $this->db->order_by("category_id", "desc"); 
        $query_result=  $this->db->get();
        $results = $query_result->result();
        return $results;
    } 
    public function selectBanner($banner_id)
    {
        $this->db->select('*');
        $this->db->from('tbl_banner');
        $this->db->where('banner_id',$banner_id);
        //$this->db->order_by("product_id", "desc"); 
        $query_result = $this->db->get();
        $results = $query_result->result();
        return $results;
    } 
$
意见:
home_message:::
<?php foreach ($result as $values)  { ?>
<div class="single_product">
<div class="product_image">
        <a href="<?php echo base_url(); ?>home/category/<?php echo   $values->category_id ?>"><img src="<?php echo base_url();?><?php echo $values->category_image ?>" /></a> 
    </div>
    <span class="category_title"> <a href="<?php echo base_url(); ?>home/category/<?php echo $values->category_id ?>"> <?php echo $values->category_name ?></a> </span>
 </div>
<?php } ?>
横幅
<div>
<?php foreach ($bannerInfo as $values) {   ?>
<?php echo $values->banner_image ?>
<?php } ?>
</div>