Bman900 Posted April 12, 2010 Share Posted April 12, 2010 I was wondering if this is correct or there is a better way of doing this? <?php $result = mysql_query("SELECT * FROM newsletter"); while($row = mysql_fetch_assoc( $result )) { $email = $row; mail($email, $subject, $message,"From: $from_email\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"); echo "$email was sent!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/198310-would-this-while-statement-work/ Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 The while statement is correct; however, $row is an array, so... Quote Link to comment https://forums.phpfreaks.com/topic/198310-would-this-while-statement-work/#findComment-1040537 Share on other sites More sharing options...
Jax2 Posted April 12, 2010 Share Posted April 12, 2010 Is the only thing you need from the database the email? You'll need to specify which row: $email = $row['email']; Quote Link to comment https://forums.phpfreaks.com/topic/198310-would-this-while-statement-work/#findComment-1040538 Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 Technically, that's a column, not a row. $row contains the array of results for the row. Quote Link to comment https://forums.phpfreaks.com/topic/198310-would-this-while-statement-work/#findComment-1040541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.