86Stang Posted June 11, 2009 Share Posted June 11, 2009 I need to include the list of members that are about to be purged in an email that will be mailed to a manager. This will be put into a daily cronjob. I've got it all figured out with the exception of displaying the members in the email. <?php // time settings. $time = time() - (60*60*72); // change the last digit to the number of hours in the past you want to range to. $query = mysql_query("SELECT * FROM table WHERE join_date >" . $time); $number = mysql_num_rows($query); // display all deleted members while($row = mysql_fetch_array($query)) { echo $row['username'] . "<br />"; } // mail settings $to = "[email protected]"; $subject = "Automated removal of pending members"; $message = "This is an automated message letting you know that the server has removed $number pending members that are 72 hours old or older that never activated their account."; $from = "[email protected]"; $headers = "From: $from"; // mail it out! mail($to,$subject,$message,$headers); ?> How do I stuff the names of the members that I looped into $message? Am I doing it wrong by looping? Should it be an array maybe? Any help would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/161835-solved-including-a-list-of-records-in-an-email/ Share on other sites More sharing options...
taquitosensei Posted June 11, 2009 Share Posted June 11, 2009 try this while($row = mysql_fetch_array($query)) { $members.=$row['username']. "\r\n"; } then this $to = "[email protected]"; $subject = "Automated removal of pending members"; $message = "This is an automated message letting you know that the server has removed $number pending members that are 72 hours old or older that never activated their account."\r\n".$member; $from = "[email protected]"; $headers = "From: $from"; Link to comment https://forums.phpfreaks.com/topic/161835-solved-including-a-list-of-records-in-an-email/#findComment-853846 Share on other sites More sharing options...
86Stang Posted June 11, 2009 Author Share Posted June 11, 2009 You had $members in the first snippet and $member in the second but outside of that it worked like a charm! Now, so I can take something from this -- what is the point of the . after $members here: $members.=$row['username']. "\r\n"; Since this is a loop, I'm guessing it's saying "add the incoming username to the $members variable" (?) Link to comment https://forums.phpfreaks.com/topic/161835-solved-including-a-list-of-records-in-an-email/#findComment-853856 Share on other sites More sharing options...
Hatdrawn Posted June 11, 2009 Share Posted June 11, 2009 the " .= " adds to the current information in the variable http://www.w3schools.com/PHP/php_operators.asp Link to comment https://forums.phpfreaks.com/topic/161835-solved-including-a-list-of-records-in-an-email/#findComment-853863 Share on other sites More sharing options...
taquitosensei Posted June 11, 2009 Share Posted June 11, 2009 It concatenates $member.="whatever"; is the same thing as $member=$member."whatever"; Link to comment https://forums.phpfreaks.com/topic/161835-solved-including-a-list-of-records-in-an-email/#findComment-853984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.