php - How to send data in array to database -
i getting value input box in array. want post database single insert query relevent data inserted in mysql
here code
foreach ($_post['stop'] $stopindex => $stopvalue) { echo $stopname=$stopvalue; } foreach ($_post['timing'] $timingindex => $timingvalue) { } foreach ($_post['ampm'] $ampmindex => $ampmvalue) { }
can me correct code write insert query
this example if use codeigniter's way of fetching data.
just prepare 1 array appropriate keys (relevant database keys defined) , import update_batch ci db method.
this method 1 can use in model.
function save_something() { $post_data = $this->input->post(); foreach ($post_data $key => $value) { $settings[] = array( 'key' => $key, 'value' => $value); } } $this->db->update_batch('settings',$settings,'key'); return true; }
Comments
Post a Comment