SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Brooklyn, NY
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    beyond the scope of mail()?

    I'm attempting create a script where newsletter subscribers can receive their specific state assembly rep info in the body of emails sent out to them. The script pulls subscriber info from one table (including email address), assembly rep info in another (including district# & contact info), and a third lookup table mapping subscriber record ID's & rep record ID's. Currently, everyone who is emailed receives the information from the first rep record row instead of their specific rep info. Though I can echo these results properly, mail () sends only the first row of the rep table. Is it possible to remedy this? Any help would be much appreciated to alleviate days of intense brain racking.

    Here's the script:
    PHP Code:
    <?php 

    $sql
    "select Lookup.ID, Lookup.ADIS, subscr.ID as userid, subscr.EmailAddress, assembly.* from Lookup 
    left join subscr on subscr.ID = Lookup.ID 
    left join assembly on assembly.ID = Lookup.ADIS 
    where assembly.ID != 'NULL' and Lookup.ADIS != 'NULL'"

    $result=mysql_query($sql); 

    $num_rows=@mysql_num_rows($result); 
    if ( 
    $num_rows == ) { 
    echo 
    "Sorry no newsflashes were sent"
    } else { 

    echo 
    "Email Results : $num_rows *"


    $to "Newletter List<list@theproject.org>" ", "
    $subject "$subject"
    $headers .= "MIME-Version: 1.0\n"
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n"
    $headers .= "Content-Transfer-Encoding: 7bit\n"
    $headers .= "From: Project Editor<editor@theproject.org>\n"
    $headers .= "Reply-to: Editor<editor@theproject.org>\n"
    $headers .= "$priority\n"
    $headers .= "Return-Path: <webmaster@theproject.org>\n"
    while(
    $row=mysql_fetch_array($result)) { 
    $htmlmessage "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"> 
    <HTML><BODY> 
    <head> 
    <META http-equiv=\"Content-Type\" content=\"text/html;\"> 
    <title>NY Natural Health Project * NEWSFLASH *</title> 
    <link href=\"http://www.nynaturalhealthproject.org/ht/nynhp.css\" rel=\"stylesheet\" type=\"text/css\"> 
    <style type=\"text/css\"> 
    <!-- 
    </style> 
    </head> 
    <body bgcolor=\"#ffffff\" text=\"#000000\" topmargin=\"0\" 
    leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" 
    marginheight=\"0\" link=\"#666699\" vlink=\"#9cc99\"><div align=\"center\"> 
    <TABLE cellspacing=\"0\" cellpadding=\"1\" width=\"600\" bgcolor=\"#99cc99\"> 
    <TR> 
    <TD> 
    <table cellspacing=\"0\" cellpadding=\"4\" width=\"600\" bgcolor=\"#ffffff\" border\"2\"> 
    <tr> 
    <td width=\"100%\" colspan=\"2\"><div align=\"left\"> 
    <img src=\"http://www.nynaturalhealthproject.org/gr/NYlogogrnsm.gif\" width=\"115\" height=\"86\" border=\"0\" alt=\"NYNHP Logo\" style=\"float: left;\"><img src=\"http://www.nynaturalhealthproject.org/gr/tagline.gif\" width=\"485\" height=\"86\" border=\"0\" alt=\"tag line\"></div> 
    <img src=\"http://www.nynaturalhealthproject.org/gr/x.gif\" width=\"600\" height=\"1\" border=\"0\"> 
    <font size=\"2\" color=\"#000000\" face=\"Verdana, Arial, Helvetica\">* 
    Please note what we show to be your state representative contact information below: *</font> 
    </td> 
    </tr> 
    <tr> 
    <td colspan=\"2\"> 
    <p><font size=\"2\" color=\"#000000\" face=\"Verdana, Arial, Helvetica\">
    $body 
    </font></p></TD> 
    </TR> 
    <tr> 
    <td colspan=\"2\"> 
    <img src=\"http://www.nynaturalhealthproject.org/gr/x.gif\" width=\"600\" height=\"1\" border=\"0\"> 
    </td></tr> 
    <tr><td width=\"50%\"><p><font size=\"2\" color=\"#000000\" face=\"Verdana, Arial, Helvetica\"> 

    Assembly District 
    $row[ADIS]<BR> 
    $row[arep]<BR><BR> 

    District Office1<BR> 
    $row[adstreet1]<BR> 
    $row[adcsz1]<BR> 
    $row[adtel1]<BR> 
    <BR> 
    District Office2<br> 
    $row[adstreet2]<br> 
    $row[adcsz2]<br> 
    $row[adtel2]<br> 
    <br> 
    Albany Office<br> 
    $row[alob]<br> 
    $row[alobcsz]<br> 
    $row[alobtel]<BR> 
    <a href=\"mailto:
    $row[alobemail]\">$row[alobemail]</a></font></p> 
    </td><td> 

    </td></tr> 
    </TABLE></TD> 
    </TR> 
    </TABLE></div>- 
    $row[userid] 
    </body></html>"


    $textmessage "<!--(* Please note what we show to be your state representative contact information below: *) 

    $textbody 

    Assembly District 
    $row[ADIS] 
    $row[arep] 

    District Office1 
    $row[adstreet1] 
    $row[adcsz1] 
    $row[adtel1] 

    District Office2 
    $row[adstreet2] 
    $row[adcsz2] 
    $row[adtel2] 

    Albany Office 
    $row[alob] 
    $row[alobcsz] 
    $row[alobtel] 
    $row[alobemail] 

    $row[userid]-->"
    $textmessage .= "\n"
    $headers .= "Bcc: $row[EmailAddress]\n"

    $message $textmessage.$htmlmessage

    mail($to$subject$message$headers); 
    exit; 
    ?>
    Thanks.

    -Bagelmaster
    Last edited by bagelmaster; May 15, 2003 at 19:58.

  2. #2
    SitePoint Guru coiL's Avatar
    Join Date
    Sep 2001
    Location
    QLD, Australia
    Posts
    666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    To make it easier please enclose any code you post in code or php tags (the buttons with # and <? on them)

    Also you need to use
    PHP Code:
     $row['field_name'
    Also you can't just have variables sitting in the middle of html [img]images/smilies/smile.gif[/img]
    Code:
     $msg = "<body> <h1> hello " . $name ."</h1></body>";
    coiL
    "cradled in the learning curve"

  3. #3
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Brooklyn, NY
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The $body & $textbody variables are being passed through from a form & include file - code for which I omitted.

    -Bagelmaster


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •