Currently I have an Array that looks like the following when output thru print_r();
Array
(
[0] => Array
(
[R_ID] => 32
[email] => [email protected]
[name] => Bob
)
[1] => Array
(
[R_ID] => 32
[email] => [email protected]
[name] => Dan
)
[2] => Array
(
[R_ID] => 32
[email] => [email protected]
[name] => Paul
)
[3] => Array
(
[R_ID] => 35
[email] => [email protected]
[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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…