RE: [PHP] Email Selected Data
you need to have the $content line with (.) operator: for ($i=0; $i$num_rows; $i++) { mysql_data_seek($SQLResult, $i); $array=mysql_fetch_array($SQLResult); $content .= printf("First Name: %s\nLast Name: %s\n",$array['FirstName'], $array['LastName']); } mail($MAIL, "Order", $content , "From:[EMAIL PROTECTED]"); Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, February 05, 2001 5:32 AM To: [EMAIL PROTECTED] Subject: [PHP] Email Selected Data Hi, I am selecting data using the below and trying to insert it into a mail, it does everything except send the data selected, anyone have an idea? $SQLStatement = "SELECT * FROM Orders Where Status='N' Order by OrderID"; $SQLConn = mysql_connect($host, $user, $pass); $db = mysql_select_db($dbase, $SQLConn); $SQLResult = mysql_query($SQLStatement); $num_rows=mysql_num_rows($SQLResult); for ($i=0; $i$num_rows; $i++) { mysql_data_seek($SQLResult, $i); $array=mysql_fetch_array($SQLResult); $content=printf("First Name: %s\nLast Name: %s\n",$array['FirstName'], $array['LastName']); } mail($MAIL, "Order", $content , "From:[EMAIL PROTECTED]"); I know it is working to a degree because it prints out the data on the resulting page and sends a blank email, it just doesn`t put it in the email. TIA Ade -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Email Selected Data
On Mon, 5 Feb 2001 07:01, [EMAIL PROTECTED] wrote: Hi, I am selecting data using the below and trying to insert it into a mail, it does everything except send the data selected, anyone have an idea? $SQLStatement = "SELECT * FROM Orders Where Status='N' Order by OrderID"; $SQLConn = mysql_connect($host, $user, $pass); $db = mysql_select_db($dbase, $SQLConn); $SQLResult = mysql_query($SQLStatement); $num_rows=mysql_num_rows($SQLResult); for ($i=0; $i$num_rows; $i++) { mysql_data_seek($SQLResult, $i); $array=mysql_fetch_array($SQLResult); $content=printf("First Name: %s\nLast Name: %s\n",$array['FirstName'], $array['LastName']); } mail($MAIL, "Order", $content , "From:[EMAIL PROTECTED]"); I know it is working to a degree because it prints out the data on the resulting page and sends a blank email, it just doesn`t put it in the email. TIA Ade I think your logic is wrong here, if you are trying to send one email with all the results from the DB query in it. Each time you run through the for loop, you are assigning a new value to $contents, rather than appending new information to it. I think you need $content .= printf(blah blah); or without the printf complexity $content .= "First Name: " . $array["FirstName"] . "\nLast Name: " . $array["LastName"] . "\n"; You'ld need to ensure $content is empty before starting the for loop, of course. -- David Robley| WEBMASTER Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]