Opps, last messages had the definition of $originalMessage in the wrong place. Try this: If ($button != "") { $t = mysql_query("SELECT * from AddExisting"); $number_of_customers = mysql_num_rows($t);
$originalMessage = $message; for($i=0; $i<$number_of_customers;$i++) { $r = mysql_fetch_array($t); $email = $r["EMAIL_ADDRESS"]; $cusname = $r["Name"]; $to = $email; $subject = "hello"; $message = "Dear $cusname,".$originalMessage; $fromaddress = "[EMAIL PROTECTED]"; mail($to, $subject, $message, $fromaddress); }//end of for }//end of if * * Cal Evans * Techno-Mage * http://www.calevans.com * ----- Original Message ----- From: "Kris Vose" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 20, 2002 2:07 PM Subject: [PHP] for loop problem I have a problem with a piece of code that uses the mail function in a for loop. It sends out mail to all the users in the database but it has a problem with attaching their specific name into the message. What happens is the first user in the database will get their name in the e-mail (Dear John,). Then the second user in the database will get the last users name and their name in the e-mail (Dear John, Dear Mike) ...and so on and so forth. How do I fix this problem? Your help is appreciated. Here is the code: If ($button != "") { $t = mysql_query("SELECT * from AddExisting"); $number_of_customers = mysql_num_rows($t); for($i=0; $i<$number_of_customers;$i++) { $r = mysql_fetch_array($t); $email = $r["EMAIL_ADDRESS"]; $cusname = $r["Name"]; $to = $email; $subject = "hello"; $message = "Dear $cusname,".$message; $fromaddress = "[EMAIL PROTECTED]"; mail($to, $subject, $message, $fromaddress); }//end of for }//end of if -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php