2011-09-01 54 views
1

如何能輸入$_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 
+0

你正在使用什麼數據庫抽象層? – Rijk

+0

我使用mysql。 –

回答

1

如果你沃爾德要插入「喬治·庫爾達爾」串到DB你應該concatinate串.

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

或者,如果你有「名」和DB「姓」字段:

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