基本上通过显示一个表单,其中用户可以输入2个变量$ no和$ first,但我只能在输入两个字段时显示结果。我需要它的工作,所以当我输入1个变量时,它会显示结果。Codeigniter搜索查询不能正常工作
我想我可以使用某种OR语句,但我不确定如何实现它。任何帮助将不胜感激,我很抱歉,如果它不够清楚,我谈到codeigniter时是相当新的。
控制器
public function query()
{
$no = $this->input->post('no');
$first = $this->input->post('first');
$this->load->model("test");
$data['query']=$this->test->query($no,$first);
$this->load->view('query',$data);
}
型号
function query($no, $first)
{
return $query = $this->db->get_where('table', array('no' => $no,
'first' => $first))->result();
}
查看
<?php foreach($query as $row): ?>
<tr>
<td><?php echo $row->no; ?></td>
<td><?php echo $row->date; ?></td>
<td><?php echo $row->first; ?></td>
</tr>
<?php endforeach; ?>
只有在no等于$ no的情况下才有效,我读到他需要或者需要的问题。 –