I’ve been trying all sorts to get this to work, I have a table that contains emails due to go out. The reason is, rather than sending dozens of similar emails, I’d rather store them and send them every 24 hours to each recipient with the data collated into one single email.
So I’ve got from, to, subject and message fields, I want to find all the ones going to the same address and have them in an array with that email address as the key.
So I could then go through the array, using the key as the to field in the mail function and loop through processing the contents into one single email before it’s sent.
If anyone knows how I could do this either with MySQL query or in PHP that’d be awesome.
Thanks.
I’ve got this, but it’s not working as I hoped, I’ve only got one of each in the array, when the database stores several same value groups in the to field.
while($data = mysql_fetch_assoc($query)){
$array[$data['to']] = $data;
}
you’re always rewriting the $data instead of appending the new message
you need to create asociative array and only append the message at the end.
something like