Canman2005 Posted March 20, 2006 Share Posted March 20, 2006 Dear allI have a php email script which sends a bunch of data to a specified email address. I want to also include a list of file names stored in a sql database along with the email.The part of the email script which builds the email looks like[code]$header .= "X-MSMail-Priority: Normal\n";$header .= "X-Mailer: php\n";$subject = "Information";$body = "<html><body>The following is your data. Please contact us</body></html>";[/code]I run a normal query a the top of the page and want to include the list of files attached to there name in the database, I have tried to print the files using[code]while ($row = mysql_fetch_array($files)) { print "$row[files]" }[/code]When used on a page the above is fine, but I cannot seem to combine it into the email body, I tired the code below but it didnt like it;[code]$header .= "X-MSMail-Priority: Normal\n";$header .= "X-Mailer: php\n";$subject = "Information";$body = "<html><body>The following is your data"while ($row = mysql_fetch_array($files)) { print "$row[files]" }"Please contact us</body></html>";[/code]But it cant seem to print the list of$rows[files]Any ideas? If this makes sense to anyone.ThanksEd Quote Link to comment Share on other sites More sharing options...
trq Posted March 20, 2006 Share Posted March 20, 2006 [code]$body = "<html><body>The following is your data";while ($row = mysql_fetch_array($files)) { $body .= $row['files'];}$body .= "Please contact us</body></html>";[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 20, 2006 Share Posted March 20, 2006 You need to add the files to the body of the message:[code]<?php$header .= "X-MSMail-Priority: Normal\n";$header .= "X-Mailer: php\n";$subject = "Information";$body = "<html><body>The following is your data:<br>";while ($row = mysql_fetch_array($files)) $body .= $row[files] . '<br>';$body .= "Please contact us</body></html>";?>[/code]The "print" statement you used would have just put the info onto your screen.Ken Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 20, 2006 Author Share Posted March 20, 2006 Thanks everyone[!--quoteo(post=356701:date=Mar 20 2006, 06:38 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 20 2006, 06:38 PM) [snapback]356701[/snapback][/div][div class=\'quotemain\'][!--quotec--]You need to add the files to the body of the message:[code]<?php$header .= "X-MSMail-Priority: Normal\n";$header .= "X-Mailer: php\n";$subject = "Information";$body = "<html><body>The following is your data:<br>";while ($row = mysql_fetch_array($files)) $body .= $row[files] . '<br>';$body .= "Please contact us</body></html>";?>[/code]The "print" statement you used would have just put the info onto your screen.Ken[/quote] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.