Forum Moderators: coopster

Message Too Old, No Replies

send while in an email

         

helenp

1:19 pm on Oct 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi, I have a while statement that gets information from a select mysql, and at the same time that while statement has more mysql selects inside. And I need to send the results by that while in an email with mail(). Is it posible and if so, how? I am really stuck on this.

dreamcatcher

7:29 am on Oct 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi helenp,

Simply concatenate your string:

$string = '';

while ($something = mysql_fetch_object($row)) {
$string .= '';
}

mail (email,subject,trim($string),headers);

dc

helenp

7:28 pm on Oct 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Dreamcatcher.
I have tried it as you sugested however get an empty email.
This is the testfile I did (just to check it works, not my file). Something must be wrong, but what?.
<?php
$para = 'my_email@gmail.com';
$asunto = 'Test';
$cabeceras = 'MIME-Version: 1.0' . "\r\n";
$cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$cabeceras .= 'From: ' . "\r\n";
$lol = 1;
$string = '';
while ($lol < 10) {
echo $lol;
$lol++;
$string .= '';
}

mail ($para,$asunto,trim($string),$cabeceras);
?>
On the webpage I get as a result 123456789, which is correct however I get an empty email file.

cameraman

5:58 am on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here:
while ($lol < 10) {
echo $lol;
$lol++;
$string .= '';
}

You're concatenating an empty string onto the string. Try:
while ($lol < 10) {
echo $lol;
$string .= $lol;
$lol++;
}

helenp

10:04 pm on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks a lot,
it works as a charm.