【问题标题】:"Unable to load the requested file: search_result.php" error“无法加载请求的文件:search_result.php”错误
【发布时间】:2015-04-13 08:33:58
【问题描述】:

我想创建一个搜索框,我们输入学生姓名然后显示该学生的所有记录。我的控制器代码是

public function search_function_in_controller()
    {
           if ($this->session->userdata('admin_login') != 1)
            redirect('login', 'refresh');
           $keyword = $_POST['keyword']; // you can also use $this->input->post('keyword');

            $data['search_result'] = $this->crud_model->search($keyword);
            $this->load->view('search_result', $data);
    }

我的模型是:

function search($keyword)
    {
        $this->db->like('name',$keyword);
        $query  =   $this->db->get('student');
        return $query->result();
    }

我的看法是:

<body>
<form action="<?=site_url('admin/search_function_in_controller')?>" method="post">
  search: <input type="text" name="keyword" />
  <input type="submit" value="Submit" />

</form> 
<div>
    <?php
        // List up all results.
        foreach ($results as $val)
        {
            echo $val['username'];
        }
    ?>
</div>
</div>
</body>

但是当我们在搜索框中输入时,它会给出“无法加载请求的文件:search_result.php”,有人可以帮我吗??

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    验证您在视图中调用的路径。

    我认为您打算在您的函数search_function_in_controller 中调用视图admin/search_result

    【讨论】:

      猜你喜欢
      • 2018-10-01
      • 2019-06-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-25
      • 2018-07-20
      • 1970-01-01
      • 1970-01-01
      • 2017-07-09
      相关资源
      最近更新 更多