I need to pa开发者_开发百科ss two variables to a page and i'm not sure would i do it. I need to tell it to load a specific view and also pass sql results to this view.
// template.php
<?php
$this->load->view('includes/header');
$this->load->view($main_content);
$this->load->view('includes/footer');
?>
// my controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MyController extends CI_Controller {
    function query()
    {
        $this->load->model('search');
        $data['main_content'] = 'query_results';
        $sql['rows'] = $this->search->getAll();
        $this->load->view('includes/template', $data, $sql); // no clue how to pass $sql to the view
    }
}
?>
Thanks a lot in advance for your help.
You should change your function to
function query()
{
    $this->load->model('search');
    $data['main_content'] = 'query_results';
    $data['rows'] = $this->search->getAll();
    $this->load->view('includes/template', $data);
}
Now you can access your results in the view via the variable $rows.
You can find the reference here, section "Adding Dynamic Data".
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论