inbowns Posted April 20, 2011 Share Posted April 20, 2011 I really need help with this I have a php script that queries the database and then sends a separate email but I was just recently told they would like each query to to be put in an email so we only send one like the way i made it below (sorry if it's sloppy) if anyone can help I would greatly appreciate it. Thanks in advance ___________________________________ Name | Date | Address | State | _______|_____|______________|______ | John | 3/18 | 215 5th Street | NY | ______ |____ |______________|______ | Bob | 4/15 | 505 North Street | NY | ______ |____ |_____________ |______ | Jane | 5/9 | 6 main Street | MD | ______ |____|_______________ | ______| Ann | 1/12 | 9 West Ave | CA | ______ |____ |_______________|______ | Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/ Share on other sites More sharing options...
mens Posted April 20, 2011 Share Posted April 20, 2011 Switch the email encoding to HTML, and then use a table element. $data .= '<table>' . ' <tr>' . ' <td>'; { .. continue as per usual .. } $em = mail('[email protected]', 'subject', $data, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/#findComment-1204095 Share on other sites More sharing options...
inbowns Posted April 20, 2011 Author Share Posted April 20, 2011 I tired it but it didn't work. Are saying I should use concatentation? Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/#findComment-1204135 Share on other sites More sharing options...
mens Posted April 20, 2011 Share Posted April 20, 2011 How you build the data does not matter, it's all good. If I'm guessing correct, you're not using the MIME or content type headers. This would render the email completely just as text. Please refer to [link=http://php.net/manual/en/function.mail.php]mail()[/link] in the manual for more information. Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/#findComment-1204200 Share on other sites More sharing options...
inbowns Posted April 21, 2011 Author Share Posted April 21, 2011 I have the mime setting on please see what i have posted below $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; Here's how my script looks that I'm working with. <th>Broker</th><th>Lives</th><th>Quote</th> <?php $connection = mysql_connect("localhost", "root", "") or die (mysql_error()); $db = mysql_select_db ("health",$connection) or die (mysql_error()); $query = "SELECT * FROM data"; $result = mysql_query( $query, $connection) or die(mysql_error()); $num_results = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $broker = $row ["broker"]; $client = $row ["client"]; $lives = $row ["lives"]; $email = $row ["email"]; $broker = ucwords(strtolower($broker)); $client = ucwords(strtolower($client)); $broker; // break the string into words. $words = explode(' ',$broker); // reverse the array of words using array reverse $words = array_reverse($words); // implode rebuild the string $broker = implode(' ',$words); $broker = substr($broker, 0, -1); if ($lives == 8 ) { echo " <table> <tr> <td> $broker </td> <td> $lives </td> <td> $quote </td> <td> $email </td> </tr> </table> "; //$email2 = ""; $address = ""; //$address = ""; $subject = "You have a broker that is quoting a group with more than 10 lives"; $body = " <html> <head> <title></title> </head> <body> Upon review of data from $program we found that you a have broker that is quoting groups over 10 lives.<br> It would be best to contact your broker to see if they are in need of your assistance.<br> <br> <br> <table> <tr> <td> Broker's Name: </td> $broker.='<td>'. <b>$broker</b> </td> </tr> <tr> <td> Client: </td> <td> <b>$client</b> </td> </tr> <tr> <td> Lives </td> <td> <b>$lives</b> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <br> <br> PLEASE DO NOT RESPOND THIS EMAIL WAS AUTOMATICALLY GENERATED <br> <br> <font size = 1>This transmission is intended only for the use of the individual or entity to which it is addressed. It may contain information that is privileged or confidential, and may be protected by State and/or Federal Regulations. If the Reader of this transmission is not the intended recipient, or the agent responsible for delivering the transmission to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this transmission is strictly prohibited. If you have received this communication in error, please delete it and all of the attachments </font> $broker.='<td>.' </body> </html> "; // Always set content-type when sending HTML email $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $mailheaders = "From: \r\n"; mail($address, $subject, $body, $headers); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/#findComment-1204455 Share on other sites More sharing options...
Nodral Posted April 21, 2011 Share Posted April 21, 2011 Do a google for Rmail It'll solve all your html or attachement problems Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/#findComment-1204463 Share on other sites More sharing options...
mens Posted April 21, 2011 Share Posted April 21, 2011 How does the email actually look? Your script looks fine to me. But it'd also suggest using a pre-constructed class such as Rmail, as it makes life much easier. Quote Link to comment https://forums.phpfreaks.com/topic/234279-mail-problem/#findComment-1204547 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.