mail() and mysql

Hi everyone

I am trying to send a e-mail using the mail() function.
Now i try to send more than one data from mysql database so i must use
example

$results=mysql_num_rows($result_query)
for(i=0; $i < $results; i++)
{
$row=mysql_fetch_array($result_query);
echo $row['name'];
echo " ";
echo $row['blabla'];
}

if i use mail() function one parametar must be variable example $text

I cant put more than one parameter in mail function or if i use $text
variable in string i cant put for()..etc

example

$text ="This is costumers names".
for(i=0; $i < $results; i++)
{
$row=mysql_fetch_array($result_query);
echo $row['name'];
echo " ";
echo $row['blabla'];
}." ..etc";

This is no working solution

mail(some [at] some.so, help, $text);

I am new in php programing and i have no idea how to do this.
Thanks Ivan
Bandul [ Mi, 26 April 2006 01:24 ] [ ID #1290522 ]

Re: mail() and mysql

Bandul wrote:
> Hi everyone
>
> I am trying to send a e-mail using the mail() function.
> Now i try to send more than one data from mysql database so i must use
> example
>
> $results=mysql_num_rows($result_query)
> for(i=0; $i < $results; i++)
> {
> $row=mysql_fetch_array($result_query);
> echo $row['name'];
> echo " ";
> echo $row['blabla'];
> }
>
> if i use mail() function one parametar must be variable example $text
>
> I cant put more than one parameter in mail function or if i use $text
> variable in string i cant put for()..etc
>
> example
>
> $text ="This is costumers names".
> for(i=0; $i < $results; i++)
> {
> $row=mysql_fetch_array($result_query);
> echo $row['name'];
> echo " ";
> echo $row['blabla'];
> }." ..etc";

This is the same and less code, if you want to limit number of fetches, use
LIMIT in your SQL-query.

$text ="This is costumers names".
while($row=mysql_fetch_array($result_query)) {
echo $row['name'];
echo " ";
echo $row['blabla'];
}

> This is no working solution
>
> mail(some [at] some.so, help, $text);

If you want to store something in a variable, then don't use echo, as it will
always go to stdout (in this case the webserver).

$text ="This is costumers names".
while($row=mysql_fetch_array($result_query)) {
$text .= $row['name'];
$text .= " ";
$text .= $row['blabla'];
}

mail(some [at] example.net, "Customer info", $text,'From: webmaster [at] example.com');

the '.=' is used to append text to a variable, which makes it easy to build
string of text as an auto generated list of data that will be sent with mail().



//Aho
Shion [ Mi, 26 April 2006 06:06 ] [ ID #1290523 ]

Re: mail() and mysql

Thanks

"J.O. Aho" <user [at] example.net> wrote in message
news:4b89tfF106ukfU1 [at] individual.net...
> Bandul wrote:
>> Hi everyone
>>
>> I am trying to send a e-mail using the mail() function.
>> Now i try to send more than one data from mysql database so i must use
>> example
>>
>> $results=mysql_num_rows($result_query)
>> for(i=0; $i < $results; i++)
>> {
>> $row=mysql_fetch_array($result_query);
>> echo $row['name'];
>> echo " ";
>> echo $row['blabla'];
>> }
>>
>> if i use mail() function one parametar must be variable example $text
>>
>> I cant put more than one parameter in mail function or if i use $text
>> variable in string i cant put for()..etc
>>
>> example
>>
>> $text ="This is costumers names".
>> for(i=0; $i < $results; i++)
>> {
>> $row=mysql_fetch_array($result_query);
>> echo $row['name'];
>> echo " ";
>> echo $row['blabla'];
>> }." ..etc";
>
> This is the same and less code, if you want to limit number of fetches,
> use LIMIT in your SQL-query.
>
> $text ="This is costumers names".
> while($row=mysql_fetch_array($result_query)) {
> echo $row['name'];
> echo " ";
> echo $row['blabla'];
> }
>
>> This is no working solution
>>
>> mail(some [at] some.so, help, $text);
>
> If you want to store something in a variable, then don't use echo, as it
> will always go to stdout (in this case the webserver).
>
> $text ="This is costumers names".
> while($row=mysql_fetch_array($result_query)) {
> $text .= $row['name'];
> $text .= " ";
> $text .= $row['blabla'];
> }
>
> mail(some [at] example.net, "Customer info", $text,'From:
> webmaster [at] example.com');
>
> the '.=' is used to append text to a variable, which makes it easy to
> build string of text as an auto generated list of data that will be sent
> with mail().
>
>
>
> //Aho
Bandul [ Mi, 26 April 2006 11:07 ] [ ID #1290525 ]
PHP » alt.php.sql » mail() and mysql

Vorheriges Thema: mysql query
Nächstes Thema: CoderWiki.com - A free online reference manual