Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please I need help for a script 1

Status
Not open for further replies.

ejgarcia

IS-IT--Management
May 28, 2003
72
US
Hello all,

I have a DB with 10 emails, fisrtname and lastname. And I need to send an email to each customer but it must contain the first name and the last name on the body of the email...

Thanks you,
 
mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])

so:

1. issue the sql query in order to get:
$mail_address
$name
$last_name

2. set the subject and body message:

$subj = "Subject is here.";
$body_mes = "Dear " . $name . " " . $last_name .",\n\n";
$body_mes .= "blah blah blah...\n";

4. mail($mail_address, $subj, $body_mes);

Cheers.
 
Hello Chacalinc,

Thanks you very much, but would you be please more specific?

I'm starting programing in PHP MySQL :-(

Thanks you and regards
 
Ok, an example:

Code:
<?php
mysql_connect(&quot;localhost&quot;, &quot;mysql_user&quot;, &quot;mysql_password&quot;) or
   die(&quot;Could not connect: &quot; . mysql_error());
mysql_select_db(&quot;mydb&quot;);

$result = mysql_query(&quot;SELECT email, name, lastname FROM email_table&quot;);

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

   $mail_address = $row[0];
   $name = $row[1];
   $last_name = $row[2];

   $subj = &quot;Subject is here.&quot;;
   $body_mes = &quot;Dear &quot; . $name . &quot; &quot; . $last_name .&quot;,\n\n&quot;;
   $body_mes .= &quot;blah blah blah...\n&quot;;
   
   mail($mail_address, $subj, $body_mes);

}

mysql_free_result($result);
?>
 
Hello Chacalinc,

Thanks you very much.

Best Regards....

Eduard!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top