ok thanks! I have looked into the implode function and have tried out the following, but 2 things:
It is still writing the first email from the list only.
It is not writing the id to the database either. I need this in order to link the emails against the userid of the person logged in.
I am not sure whether it is $email I should be imploding or $selected_contacts? Or maybe its something else again?
if ($sendMessage===-1)
{
$message_footer="\r\n\r\n";
$message_subject=$_POST['email_box'].$message['subject'];
$message_body=$message['body'].$message['attachment'].$message_footer;
$headers="From: {$_POST['email_box']}";
foreach ($selected_contacts as $email=>$name)
mail($email,$message_subject,$message_body,$headers);
$oks['mails']="Mails sent successfully";
//Now lets insert into the database
$id=$_SESSION['id'];
$query="insert into external_invites (email, id) values '.implode ($email, ','), ('".$id."')";
mysql_query($query);
Thanks,
G