Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2011
    Location
    Bangladesh
    Posts
    73
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Sending mail after updating in php

    Hi Please see below,
    PHP Code:
    if ( $smpl_typ == "PPS" && $smpl_cmnts == "Approved" ){
    require(
    "connect.php");
    $buyh $_POST['buyh'];
    $buyr $_POST['buyr'];
    $artstyl_no $_POST['artstyl_no'];
    $tbl_orderid $_POST['tbl_orderid'];
    $details "SELECT smpl_col, smpl_subno, smpl_senton, cmnts_rcvon, smpl_cmnts, smpl_rmks FROM tbl_smpl WHERE  smpl_tbl_order_id='$tbl_orderid' AND smpl_typ='PPS' AND smpl_cmnts='Approved'";
    $details_result mysql_query$details)
            or die ( 
    "Couldn't get Products: ".mysql_error() );
    while ( 
    $det_row mysql_fetch_array $details_result ) )
    {
    // message
    $message " <p>Dear All<br>Please find below the sample comments for your ref of styel $artstyl_no!</p>
      <table>
            <tr>
              <th>Color</th><th>Sub no</th><th>Sub Date</th><th>Comments Date</th><th>Comments</th><th>Remarks</th>
            </tr>
    <tr><td> "
    .$det_row'smpl_col' ]."</td>
               <td> "
    .$det_row'smpl_subno' ]."</td>
              <td> "
    .$det_row'smpl_senton' ]."</td>
              <td> "
    .$det_row'cmnts_rcvon' ]."</td>
              <td> "
    .$det_row'smpl_cmnts' ]."</td>
              <td> "
    .$det_row'smpl_rmks' ]."</td></tr>    
       
      </table><p>This is an auto generated mail, no need to reply.</p><p>Thanking you<br>noreplay@yahoo.com<br>C</p>
    "
    ;
    $to  'mehidy@yahoo.com' ', '// note the comma
    //$to .= 'sultan@yahoo.com';
    // subject
    $subject "$smpl_typ comments of Buyer:$buyr Style:$artstyl_no";
    // 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: reza@yahoo.com, liton@yahoo.com' . "\r\n";
    $headers .= 'From: C <mehidy@yahoo.com>' "\r\n";
    //$headers .= 'Cc: zahir@yahoo.com' . "\r\n";
    //$headers .= 'Bcc: mehidy1984@gmail.com' . "\r\n";
    // Mail it
    mail($to$subject$message$headers);
    }

    By using above script, after updating. i am getting two mail for two row from my mysql table. but i want to get two row details in one mail. Plz see my requirement as attached.
    Attached Thumbnails Attached Thumbnails Sending mail after updating in php-mail.gif  

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,342
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    You need to take your mail() call out of the while() loop. THAT is why its sending individual emails.
    Also $message should (in the while loop) be $message .= "your message";

    Note the . before the =
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    mehidy (10-05-2012)

  • #3
    New Coder
    Join Date
    Jan 2011
    Location
    Bangladesh
    Posts
    73
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank.i got the solution.


  •  

    Posting Permissions

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