当我点击搜索按钮时,数据正在发送,我已经验证了但是 我现在点击按钮后立即收到此错误:
遇到PHP错误
严重性:警告
消息:缺少Admin :: select()
的参数1文件名:controllers / Admin.php
行号:52
如果控制器代码,则行号52是开始。
查看:
<form action="#" class="login-wrapper" method="get">
<div class="span12" align="center">
<input class="input span12 password" type="text" name="search" placeholder="search by name">
<div class="actions">
<input class="btn btn-danger" type="submit" name="sub" value="search now">
</div>
</div >
</form>
控制器:
public function select ($search){
$this->load->model('Login_model');
if(isset($_GET ['search']) && !empty($_GET['search'])) {
$search= $_GET[ 'search'];
$this->load->model('Login_model');
$result=$this->Login_model->selectorganizer($search)''
if($result)
{
$data['result']=$result;
$this->load->view('admin/show/org', $data);
}
else
{
redirect('admin/show');
}
}
}
型号:
public function selectorganizer ($search) {
$condition = "search = '" . $search . "'";
$this->db->select('*');
$this->db->from('organizer');
$this->db->where($condition);
$query = $this->db->get();
return $result = $query->result();
}
答案 0 :(得分:2)
模型文件中的条件错误
<强>模型强>
public function selectorganizer($search) {
$this->db->select('*');
$this->db->from('organizer');
$this->db->where('name', $search);// chnage your column name here
$query = $this->db->get();
$num = $query->num_rows();
if ($num > 0) {
return $result = $query->result();
} else {
return FALSE;
}
}
<强>控制器强>
public function select (){// no need to pass agrument
$this->load->model('Login_model');
if(isset($_GET['search']) && !empty($_GET['search'])) {// remove space between $_GET and search
$search= $_GET['search'];
$this->load->model('Login_model');
$result=$this->Login_model->selectorganizer($search);//semicolumn here
if($result)
{
$data['result']=$result;
$this->load->view('admin/show/org', $data);
}
else
{
redirect('admin/show');
}
}
}