mcerveni Posted January 7, 2010 Share Posted January 7, 2010 I'm trying to send multiple emails from $row['email']. When i run the script, none of the echo statements show. It also doesn't email anything. Code shown below: <?php if( $dbc = @mysql_connect('localhost','user', 'pass') ){ //connect to myblog database if( !@mysql_select_db ('stats') ){ $diestring = '<p> Could not select the database because: <b>' .mysql_error().'</b> </p>'; die ($diestring); } } else { $diestring = '<p> Could not connect to MySQL because: <b>' .mysql_error().'</b> </p>'; die($diestring); } } $sql = "SELECT * FROM stats.employee_compo LEFT JOIN stats.sched ON employee_compo.EmpID = sched.empID "; $result = mysql_query($sql) or die(mysql_error()); $row= mysql_fetch_array($result); $agentName = $row['agentName']; $sunday = $row['sunday']; $monday = $row['monday']; $tuesday = $row['tuesday']; $wednesday = $row['wednesday']; $thursday = $row['thursday']; $friday = $row['friday']; $saturday = $row['saturday']; foreach($result as $row) { echo $row['email'].","; $to = $row['email']; $subject = "Your New Scheduale"; $body = " $agentName, <br><br> Your new scheduale is shown below: <br><br> <table style='border:1px solid black; text-align:center' > <tr><th> Sunday </th> <th> Monday </th> <th>Tuesday </th> <th> Wednesday </th> <th> Thursday</th> <th> Friday </th> <th> Saturday </th> </tr> <tr> <td> $sunday </td> <td> $monday </td> <td> $tuesday </td> <td> $wednesday </td> <td> $thursday </td> <td> $friday </td> <td> $saturday </td> </tr> </table> "; if (mail($to, $subject, $body)) { echo("<p>Scheduales have been sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } } ?> Link to comment https://forums.phpfreaks.com/topic/187538-php-mail-multiple-email-addresses-please-help/ Share on other sites More sharing options...
trq Posted January 7, 2010 Share Posted January 7, 2010 I'm not going to write a tutorial on using databases with php here as there are many already on the net. Without trying to sound harsh though, your code is pretty messed up. There is a link in my signature to a book called Hudzilla. It has an entire chapter dedicated to the subject, I would suggest you take a look there. Link to comment https://forums.phpfreaks.com/topic/187538-php-mail-multiple-email-addresses-please-help/#findComment-990181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.