Person Posted May 3, 2007 Share Posted May 3, 2007 Ok, so the Query part works, now i just need to E-mail the result in an E-mail form to someone. Could some help me out with the code. <?php $host = "localhost"; $user = "user_user"; $pass = "password"; $dbname = "user_user"; $con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $query= "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND `date` = '20070418'"; echo $query; $result= mysql_query($query); $num_results = mysql_num_rows($result); for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo "Clicks: " . $row['user_id']; } ?> <?php $email_to = "[email protected]"; $email_from = "server do not reply"; $email_title = "Total Clicks report"; $email_body ="Dear " . $user; $result= mysql_query($query); Thank you, support Site; $success = mail($to,$from,$title,$body, "From:$from\r\nReply-To:server do not reply"); ?> Link to comment https://forums.phpfreaks.com/topic/49806-e-mailing-the-result-of-a-query/ Share on other sites More sharing options...
trq Posted May 3, 2007 Share Posted May 3, 2007 <?php $host = "localhost"; $user = "user_user"; $pass = "password"; $dbname = "user_user"; $con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $query= "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND `date` = '20070418'"; echo $query; $result= mysql_query($query); $num_results = mysql_num_rows($result); for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); $clicks .= "Clicks: " . $row['user_id']; } $email_to = "[email protected]"; $email_from = "server do not reply"; $email_title = "Total Clicks report"; $email_body ="Dear $user,\n\nHere is that list of Clicks\n\n$clicks\n\nThank you,\nsupport Site;"; $success = mail($to,$from,$title,$body,"From:$from\r\nReply-To:server do not reply"); ?> Link to comment https://forums.phpfreaks.com/topic/49806-e-mailing-the-result-of-a-query/#findComment-244295 Share on other sites More sharing options...
jitesh Posted May 3, 2007 Share Posted May 3, 2007 <?php // multiple recipients $to = '[email protected]' . ', '; // note the comma $to .= '[email protected]'; // subject $subject = 'Birthday Reminders for August'; // message $message = ' <html> <head> <title>Birthday Reminders for August</title> </head> <body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td>August</td><td>1973</td> </tr> </table> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; $headers .= 'Cc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/49806-e-mailing-the-result-of-a-query/#findComment-244297 Share on other sites More sharing options...
Person Posted May 3, 2007 Author Share Posted May 3, 2007 thanks guys. Link to comment https://forums.phpfreaks.com/topic/49806-e-mailing-the-result-of-a-query/#findComment-244346 Share on other sites More sharing options...
techtheatre Posted May 3, 2007 Share Posted May 3, 2007 if this is working for you now, please be sure to mark this thread as "solved" by clicking the "topic solved" link at the bottom left corner of your post screen. Thanks! Link to comment https://forums.phpfreaks.com/topic/49806-e-mailing-the-result-of-a-query/#findComment-244381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.