Jump to content

Archived

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

Canman2005

QUERY in Email Script

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

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.