如何为搜索框创建“请求”按钮?单击请求按钮时,搜索框中输入的字母应保存在数据库中。我正在使用CodeIgniter。
答案 0 :(得分:0)
您的观点
<form method="POST" action="your-action" >
<input type="text" name="search" />
<input type="submit" value="Search" />
</form>
控制器
public function function_name()
{
$data = $this->input->post('search');
$result = $this->model_name->function_name($data);
//$result is the result/output of your search
}
MODEL
public function function_name()
{
$this->db->insert('table-name', $data);
$this->db->select('*');
$this->db->from('table-name');
$this->db->like('column-name', $data);
return $this->db->get()->result_array(); //you can also use row_array() for one record only