【问题标题】:Creating a button to save the typed data by user in database when the button is clicked创建一个按钮以在单击按钮时将用户键入的数据保存在数据库中
【发布时间】:2018-03-27 03:49:37
【问题描述】:

如何为搜索框创建“请求”按钮?单击请求按钮时,在搜索框中键入的字母应保存在数据库中。我正在使用 CodeIgniter。

【问题讨论】:

  • 您只需从 getbootstrap.com 获取引导按钮

标签: php html codeigniter


【解决方案1】:

你的看法

<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
}

型号

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 2020-08-02
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    相关资源
    最近更新 更多