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!"; } ?> 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... 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']; 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. 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
Archived
This topic is now archived and is closed to further replies.