Jump to content

PHP mail and mySQL


WatsonN

Recommended Posts

I am trying to print the contents of my database into mail function and send it but i'm not sure how this is done.

i already have the code to print all the data needed, I just don't know how to get it into the e-mail

<?php
// Connects to your Database 
mysql_connect(***) or die(mysql_error()); 
mysql_select_db("loginwatsonn") or die(mysql_error());
?>	<p>Yearbook Users</p>
<table class="listing" cellpadding="0" cellspacing="0">
                        <tr>
                            <th>ID  </th>
                            <th>UID </th>
                            <th>Ads Sold </th>
                            <th>mail </th>
                            <th>Allowed </th>
                        </tr>
                        <tr>
                          <?php 
$data = mysql_query("SELECT y.*,COUNT(ads.UID) AS posts FROM YBK_Login AS y LEFT JOIN YBK_Ads AS ads ON ads.UID=y.ID GROUP BY y.ID") or die(mysql_error()); 
while($info = mysql_fetch_array( $data )) { 
Print "<tr>"; 
Print "<td>".$info['ID'] . " </td>";
Print "<td>".$info['UID'] . "</td> ";
Print "<td>      ".$info['posts'] . " </td>";
	Print "<td>".$info['mail'] . " </td>";
Print "<td>      ".$info['Allowed'] . "</td>"; } 
?></tr></table><br><br>

 

Link to comment
https://forums.phpfreaks.com/topic/216942-php-mail-and-mysql/
Share on other sites

Thank you :) I did that and it sends the code itself instead of formatting it. What do i need to chnge?

// ---------------- SEND MAIL FORM ---------------- 
$to="[email protected]"; 
$subject="Weekly user report!"; 
$header="from: Yearbook Ads <[email protected]>"; 
$headers .= "X-Mailer: NLW\n"; 
$headers .= "X-Priority: 1\n"; 
$headers .= "Return-Path: [email protected] \n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$messages= "Here is the weekly report of all users and the ads sold. . . \r\n";
$messages .= $data;

$sentmail = mail($to,$subject,$messages,$header); 
?>

Link to comment
https://forums.phpfreaks.com/topic/216942-php-mail-and-mysql/#findComment-1127287
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.