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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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