Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

put array info into a message

the mail() function

Moderators: macek, egami, gesf

put array info into a message

Postby kermit123 » Thu Oct 13, 2011 5:50 am

Code: Select all
while($menu_info = mysql_fetch_array( $menu )) //loops to collect the data
{
   $track[]=$menu_info['track'];
   $artist[]=$menu_info['artist'];
   $request[]=$menu_info['requests'];
}
$message1 = "echo '<pre>'.print_r($track, true) .'</pre>';"
$sent = mail($to, $subject, $message1);

Basically what i want to do is get the information from a while loop then put that into a message to be emailed

can any one help please
kermit123
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Oct 13, 2011 5:45 am

Re: put array info into a message

Postby jotorres1 » Tue Nov 01, 2011 12:22 pm

I would just do it this way.

Code: Select all
<?php
    $message1 = "";
    while($menu_info = mysql_fetch_array( $menu )) //loops to collect the data
    {
       $message1 .= $menu_info['track'];
       $message1 .= $menu_info['artist'];
       $message1 .= $menu_info['requests'];
    }
    //$message1 = "echo '<pre>'.print_r($track, true) .'</pre>';"
    $sent = mail($to, $subject, $message1);
?>


For a better understanding of the mail function, I would recommend you read my post:
http://www.jotorres.com/2011/10/simple-php-send-mail/
Hope that helps.
User avatar
jotorres1
New php-forum User
New php-forum User
 
Posts: 35
Joined: Thu Oct 27, 2011 1:24 pm

Re: put array info into a message

Postby egami » Tue Nov 01, 2011 4:34 pm

and considering that you are trying to send HTML tags over the mail function, you may want to check out the php.net/mail manual page. You're missing the appropriate mime headers.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.