Jump to content

QUERY in Email Script


Canman2005

Recommended Posts

Dear all

I 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.

Thanks

Ed
Link to comment
https://forums.phpfreaks.com/topic/5360-query-in-email-script/
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/5360-query-in-email-script/#findComment-19083
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/5360-query-in-email-script/#findComment-19096
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.