php - how to email all data into a single email? -
i mailing data mysql table in php using below code, works perfectly,but problem sends each row of data single mail, want send row of data in 1 mail, how merge rows of data , send single mail? please me!!
<?php include('header.php'); session_start(); ?> <html> <head> <title>sending email using php</title> </head> <body> <?php $sql="select * products"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $to = "xyz@gmail.com"; $subject = "d2dn-viewcart"; $id_s = $row["id"]; $name_s = $row["description"]; $price_s = $row["price"] ; $message = $id_s . " " . $name_s . " " . $price_s." "; $header = "from:d2dn"; $retval = mail ($to,$subject,$message,$header); } if( $retval == true ) { echo "message sent successfully..."; } else { echo "message not sent..."; } ?> </body> </html> <?php include('footer.php'); ?>
you concatenate content , send email once:
<?php include('header.php'); session_start(); ?> <html> <head> <title>sending email using php</title> </head> <body> <?php $sql="select * products"; $result = mysql_query($sql); $to = "xyz@gmail.com"; $subject = "d2dn-viewcart"; $header = "from:d2dn"; $message = ''; while($row = mysql_fetch_array($result)){ $id_s = $row["id"]; $name_s = $row["description"]; $price_s = $row["price"] ; $message .= $id_s . " " . $name_s . " " . $price_s." "; } $retval = mail ($to,$subject,$message,$header); if( $retval == true ) { echo "message sent successfully..."; } else { echo "message not sent..."; } ?> </body> </html> <?php include('footer.php'); ?>
Comments
Post a Comment