Jump to content


Photo

QUERY in Email Script


  • Please log in to reply
3 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 20 March 2006 - 06:17 PM

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

$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>";

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

while ($row = mysql_fetch_array($files))
    {
    print "$row[files]"
    }

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;

$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>";

But it cant seem to print the list of

$rows[files]

Any ideas? If this makes sense to anyone.

Thanks

Ed

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 20 March 2006 - 06:29 PM

$body = "<html>
<body>The following is your data";

while ($row = mysql_fetch_array($files)) {
    $body .= $row['files'];
}

$body .= "Please contact us</body></html>";


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 March 2006 - 06:38 PM

You need to add the files to the body of the message:
<?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>";

?>

The "print" statement you used would have just put the info onto your screen.

Ken

#4 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 20 March 2006 - 06:59 PM

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) View Post[/div][div class=\'quotemain\'][!--quotec--]
You need to add the files to the body of the message:
<?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>";

?>

The "print" statement you used would have just put the info onto your screen.

Ken
[/quote]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users