In my database, there are only columns as email (the columns are the emails) and inside each column, there is data about that email (name of the person, etc) but this doesn't matter. I try to get all the columns as array then using implode()
to convert the array to string, so I can use the string to send an email to all columns.
This is what I tried:
$address = array();
$connection = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname, $connection);
$result = mysql_query("SHOW COLUMNS FROM `Emails`");
while($row = mysql_fetch_array($result))
{
$address = implode(',', $row);
}
If I try this: echo $row['Field']."<br>";
it shows all the columns (emails) stored in the array but when I try $address = implode(',', $result);
it's not working.
This is where the string $address
is used: mail($address,$subject,$message,$headers);