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
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="Nathan@WatsonN.com"; 
$subject="Weekly user report!"; 
$header="from: Yearbook Ads <Nathan@WatsonN.com>"; 
$headers .= "X-Mailer: NLW\n"; 
$headers .= "X-Priority: 1\n"; 
$headers .= "Return-Path: OOPS@WatsonN.com \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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.