Jump to content

Recommended Posts

Updated script

 

I need to Query the DB and then E-mail the information in a mail from the code to an E-mail address

 

$host = "localhost";
$user = "XXXX_pnke2";
$pass = "XXXX";
$dbname = "XXXXX_pnke2";

$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 = "XXXXXXX@XXXX.com";
$email_from = "XXXXX server do not reply";
$email_title = "Total Clicks report";
$email_body =Dear $user,

$result= mysql_query($query);

Thank you,
XXXXXX Site;
   $success = mail($to,$from,$title,$body,
              "From:$from\r\nReply-To:XXXXXX server do not reply");

?>

 

If someone could help me out... im new to this.

 

Regards

OK heres a basic untested and incomplete example

 


<?php 
$result= mysql_query($query);
while ($row=mysql_fetch_array($result))
{
$user = $row['user']; //<---get the idea

$email_to = "XXXXXXX@XXXX.com"; //<--See above for example
$email_from = "XXXXX server do not reply";
$email_title = "Total Clicks report";
$email_body ="Dear $user,
Thank you,
XXXXXX Site";
   $success = mail($email_to,$email_from,$email_title,$email_body,
              "From:$email_from\r\nReply-To:XXXXXX server do not reply");
} 
?>

 

 

as a note you may need to clean up the code as your not pulling the fields you need from the database (see your select statement)

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.