在一列数据库中插入$ _post?

时间:2011-09-01 09:02:27

标签: php codeigniter

如何在数据库列中插入输入$_post

"first name=George" and "last name=Kurdahi"   

$data = array('name' => $this -> input -> post('first_name') && $this -> input -> post('last_name'))
$this -> db -> insert('submits', $data)

Output: George Kurdahi

1 个答案:

答案 0 :(得分:1)

如果您希望将“George Kordahi”字符串插入DB,则应将字符串与.

连接起来
$data = array('name' => $this->input->post('first_name') . " " . $this->input->post('last_name'))

或者如果您在DB中有'name'和'surname'字段:

$data = array('name' => $this->input->post('first_name'), 'surname' => $this->input->post('last_name'))