wrigley Posted December 2, 2008 Share Posted December 2, 2008 I need to repeat the $headers .= 'Bcc: $row_rs_adm_subscribers['email']' . "\r\n"; section of the code with all the emails that are in the database. I can't just do a repeat region because it wants to repeat the entire php code section. I just need that one section <?php $to = "EMAIL ADDRESS DELETED"; $subject = "$row_rs_adm_newsletter[subject]"; $message = " <html> <head> <title>HTML email</title> </head> <body> <center> Created on $row_rs_adm_newsletter[date] $row_rs_adm_newsletter[body] </center> </body> </html> "; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: <EMAIL ADDRESS DELETED>' . "\r\n"; $headers .= 'Bcc: $row_rs_adm_subscribers['email']' . "\r\n"; mail($to,$subject,$message,$headers); ?> This would be an example of what I need... <?php $to = "EMAIL ADDRESS DELETED"; $subject = "$row_rs_adm_newsletter[subject]"; $message = " <html> <head> <title>HTML email</title> </head> <body> <center> Created on $row_rs_adm_newsletter[date] $row_rs_adm_newsletter[body] </center> </body> </html> "; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: <EMAIL ADDRESS DELETED>' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; mail($to,$subject,$message,$headers); ?> Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/135088-solved-repeat-a-php-string/ Share on other sites More sharing options...
DeanWhitehouse Posted December 2, 2008 Share Posted December 2, 2008 Use a loop. Link to comment https://forums.phpfreaks.com/topic/135088-solved-repeat-a-php-string/#findComment-703633 Share on other sites More sharing options...
wrigley Posted December 2, 2008 Author Share Posted December 2, 2008 Can you please show me how...im newer to php and not sure exactly how...not to ask to much but please use my code for the example...if you don't mind. Thanks, Nate Link to comment https://forums.phpfreaks.com/topic/135088-solved-repeat-a-php-string/#findComment-703637 Share on other sites More sharing options...
DeanWhitehouse Posted December 2, 2008 Share Posted December 2, 2008 Do you know how to get information from the db? I am assuming yes, so... <?php $sql = "SELECT * FROM table_name"; $sql = mysql_query($sql); while($rows = mysql_fetch_assoc($sql)) { $headers .= 'Bcc:'. $rows['email']. "\r\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/135088-solved-repeat-a-php-string/#findComment-703639 Share on other sites More sharing options...
wrigley Posted December 2, 2008 Author Share Posted December 2, 2008 this is what I ended up doing....thank you so much for your help! // More headers $headers .= 'From: <[email protected]>' . "\r\n"; while($row_rs_adm_subscribers = mysql_fetch_assoc($rs_adm_subscribers)) { $headers .= 'Bcc:'. $row_rs_adm_subscribers['email']. "\r\n"; } mail($to,$subject,$message,$headers); ?> Link to comment https://forums.phpfreaks.com/topic/135088-solved-repeat-a-php-string/#findComment-703649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.