基本上通過顯示一個表單,其中用戶可以輸入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的情況下才有效,我讀到他需要或者需要的問題。 –