I'm trying to create a page to send emails to contacts in my database. I started by embedding an array in the page and then used a text file, both were successful and now I'm trying to take the information from a database.

$setEmailArray = array ("email@domain.co.uk", "email@domain.com");
for($i = 0; $i < count($setEmailArray); $i++){
mail ($setEmailArray[$i], $subject, $message, $headers);

This is basically the code from the embedded array. I got the following code and I'm not sure where to go with it.

$sql = "SELECT customer_email FROM customer";
$result = mysql_query ($sql, $con );
while( $row = mysql_fetch_row ($result) )
{
  $customer_email[] = $row[1];
}
mysql_free_result( $result );

Any help would be greatly appreciated.

Thanks, Sam.

What is your actual probs here..? Sorry, i cant get you clearly...

I don't know how to get the addresses from the array to the emails.
I tried putting $customer_email into the count function and directly into the mail function, I also tried it with $row. None of them worked.

Accidentally used fetch_row instead of fetch_array - works now :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.