I have two arrays of values:
First array contain user id's:
Array ([0]=>1 [1]=>2 [2]=>3 [3]=>4 [4]=>5 [5]=>6) Second array contain attendance status:
Array([0]=>Present [1]=>Absent [2]=>Absent [3]=>Present [4]=>Absent [5]=>Present) I want to insert these values in the database in separate rows like this:
U_id Status 1 Present 2 Absent 3 Absent 4 Present 5 Absent 6 Present Currently, I am using this code to insert values in database.
My Controller Code:
public function usr_att(){ if(isset($_POST['submit'])){ $uid = $_POST['uid']; $status= $_POST['stat']; $id = implode("," , $uid ); $status = implode("," , $status ); $data = array ( 'u_id' => $id, 'status' => $status ); $this->db->insert('attendence' , $data); redirect("usr/usr_list", "refresh"); } } But this code inserts data like this:
U_id Status 1 Present,Absent,Absent,Present,Absent,Present How can I insert these values in separate rows using CodeIgniter?