Hello quick question for you guys/gals
I have a javascript object that displays as follows in the console.
Object { 10= "a@a.com", 18="b@b.com", 20="c@c.com"}
Passing this object to the backend CI Controller thru AJAX I've created the following function with CI.
function NewEMail(){
//this is the array coming from ajax
$test = $this -> input -> post('sendValue');
print_r($test);
if(is_array($test)){
foreach($test as $t){
//Insert the values in to the db from here.
}
}
}
the response from php for the print_r is as follows
Array([10] => a@a.com [18] => b@b.com [20] => c@c.com)
I would like to push each element and value to a new row as follows.
EMAIL_TABLE
| id | cus_id | email |
| 1 | 10 | a@a.com |
| 2 | 18 | b@b.com |
| 3 | 20 | c@c.com |
Where the 'id' is auto incremented how ever 'cus_id' and 'email' are read and stored from the array.
Any help or directions to helping me solve this would be greatly appreciated!
Thank you for reading, Regards.