I want to update data in a database, in page update that is, adding new input that users can add new input and put value in it.
For example, I have 2 input with values in page update (values these two input get[select] from database table and preparing for update[edit] by user) user adding 1 new input and put value in it. Now the problem is here that I want update it tow input that was edit by user and I insert new input that user put value in it, both together.
How is it?
Example from inputs: http://jsfiddle.net/aVF7M/4/
My code (is example):
$id = array('1','2','3');
$how = $this->input->post('how');
$data = array();
foreach ($how as $idx => $name) {
$data = array(
'$how' => $$how[$idx],
);
$this->db->update('hotel_units', $data, array('id' => $id[$idx]));
//$this->db->insert_batch('hotel_units', $data2);
};
You can either have a function that is fired when focus is lost. e.g. when the user edits a field (either an existing one or a new one) and clicks outside the input, the data gets serialized and sent to the URL where you handle the db interaction.
Or you could have a submit button.