I have this script to send an email containing information from my database. The user can have 1+ items in the database with it's location. So when I empty the rows that match the user the amount of emails sent equals the number of rows they have. So if they have 8 items in the database it send 8 emails. Each adds an item. So the first email has one item, the second with two items, and so on. I am trying to find a simple way to make it get all the information before sending the email so the customer only gets one email. The logical way would be to echo the information but I can't do that with a php variable. I didn't include the query and database connection in the code below. Any help would be loved.
while ($row = mysql_fetch_array($query)) {
$Items .= $row['Items']. " - Aisle " .$row['Loc']. "<p> </p>";
$to = "[email protected]";
$from = "[email protected]";
$subject = "Test";
$message = "$Items";
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "From: [email protected]";
mail($to, $subject, $message, $headers);
}
$Items
concatenated? – Fabio May 17 '13 at 17:18