Forum Moderators: coopster

Message Too Old, No Replies

sending query result by mail

         

hanyaz

9:07 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



Hi,
I am trying to send query results by mail (to setup an email alert...Here is what i am doing but it seems that i got only the first result not the full list.

function getads (){
$classifieds=mysql_query('SELECT * from matable');

while ($adslist=mysql_fetch_array($classifieds) ) {

$message=$adslist['ville'];

}

return $message;

}

$from="monmail@mail.com";
$to = "destinataire@mail.com";
$subject = "hi";
$body = getads ();

mail( $to, $subject, $body);

Thanks for any help

sned

10:59 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



Hello, in your while loop, you have

$message=$adslist['ville'];

This means that message is just getting overwritten each time the loop runs. You probably want something like:

$message .= $adslist['ville'] . "\n";

(Or some other method of breaking up the lines)

hanyaz

8:21 am on Sep 25, 2009 (gmt 0)

10+ Year Member



thanks sned..that did it !