Jump to content

[SOLVED] Including a list of records in an email


86Stang

Recommended Posts

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 = "manager@managersemail.com";
$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 = "noreply@server.com";
$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
Share on other sites

try this

while($row = mysql_fetch_array($query)) {
  $members.=$row['username']. "\r\n";
}

then this

$to = "manager@managersemail.com";
$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 = "noreply@server.com";
$headers = "From: $from";

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.