Currently I have an Array that looks like the following when output thru print_r();
Array
(
[0] => Array
(
[R_ID] => 32
[email] => a@a.com
[name] => Bob
)
[1] => Array
(
[R_ID] => 32
[email] => b@b.com
[name] => Dan
)
[2] => Array
(
[R_ID] => 32
[email] => c@c.com
[name] => Paul
)
[3] => Array
(
[R_ID] => 35
[email] => d@d.com
[name] => Mike
)
)
I would like to insert this data into one table with each element value belonging to its respective field.
Currently my php code looks like the following
if(is_array($EMailArr)){
foreach($EMailArr as $R_ID => $email => $name){
$sql = "INSERT INTO email_list (R_ID, EMAIL, NAME) values ('$R_ID', '$email', '$name')";
mysql_query($sql) or exit(mysql_error());
}
}
*Note : R_ID is NOT the primary key in this table.*
Can someone help me understand how I should approach this situation? Thank you for reading and your help!
Regards.