Person Posted May 24, 2007 Share Posted May 24, 2007 $con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $yesterday = date('20ymd', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y"))); $query = 'SELECT' . ' user,' . ' sum(imps) AS imps,' . ' sum(clicks) AS clicks,' . ' sum(clientrev) AS clientrev' . ' FROM' . ' nuke_pnAffiliate_unauditedstats' . ' WHERE' . ' `date` = ' . $yesterday . ' AND ' . ' sid like \'%rpu%\' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = \'ryan\')' . ' GROUP BY user' . ' ORDER BY clientrev DESC '; $result = mysql_query($query); $num_results = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { echo "<table>"; echo "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; echo "</table>"; } $email_to = ""; $email_from = "MAil Server Total Clicks"; $email_subject = "I dont know that to name the other tables ?."; $email_body = "Content-Type: text/html; charset=UTF-8\n"; $email_body .= "Content-Transfer-Encoding: 8bit\n\n"; $email_body .= "<table>"; "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; "</table>"; mail($email_to,$email_from,$email_subject,$email_body,"From:$email_from\are\nReply-To:do not reply to sever"); ?> This code prints this when echo : eflouret2589211629.2400002479553 mmblogpire909410526.4599993228912 uniquelink51337716.9799995422363 fosfor5327408.81999969482422 Darla3730316.84000015258789 jennklee1871295.48000001907349 stanzapub5435295.4799998998642 affiliate26006007215.28999996185303 anthroa25247244.52999997138977 iepurilah69582.01999998092651 lancelhoff7186101.88999998569489 10zenmonkeys420471.32000005245209 wildbluffmedia1198861.12999999523163 garrigus34651.09999999403954 emom73410.189999997615814 vwizard300 geeksaresexy636800 netceo1400 maloosh300 capablenetworks101900 mynetwork248800 qweszx200 now the E-mail part of this mail is not working.... i want it to print that data in a table in the E-mail that is being sent. But i dont know how to get it to print the data in the table. Right now the E-mail part does not print anything. thanks Brian Quote Link to comment https://forums.phpfreaks.com/topic/52858-printing-a-table-and-data-to-an-e-mail/ Share on other sites More sharing options...
per1os Posted May 24, 2007 Share Posted May 24, 2007 I think you are a little confused bud, try this: <?php $con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $yesterday = date('20ymd', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y"))); $query = 'SELECT' . ' user,' . ' sum(imps) AS imps,' . ' sum(clicks) AS clicks,' . ' sum(clientrev) AS clientrev' . ' FROM' . ' nuke_pnAffiliate_unauditedstats' . ' WHERE' . ' `date` = ' . $yesterday . ' AND ' . ' sid like \'%rpu%\' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = \'ryan\')' . ' GROUP BY user' . ' ORDER BY clientrev DESC '; $result = mysql_query($query); $num_results = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { echo "<table>"; echo "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; echo "</table>"; } $email_to = ""; $email_from = "MAil Server Total Clicks"; $email_subject = "I dont know that to name the other tables ?."; $email_headers = "Content-Type: text/html; charset=UTF-8\r\n"; $email_headers .= "Content-Transfer-Encoding: 8bit\r\n"; $email_headers .= "From:$email_from\r\n"; $email_headers .= "Reply-To:do not reply to sever"; $email_body .= "<table>"; "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; "</table>"; mail($email_to,$email_from,$email_subject,$email_body,$email_headers); ?> Give that a try. The content information is part of the headers. And it is not \are it is \r\n. Quote Link to comment https://forums.phpfreaks.com/topic/52858-printing-a-table-and-data-to-an-e-mail/#findComment-261082 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.