Posted By

jcroom on 08/19/09


Tagged

email php dynamic


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

jcroom
umang_nine
farondomenicgmailcom
joethermal
KrisBaur


MySQL results in email


 / Published in: PHP
 

Take the contens from a table in MySQL and display it in an email

  1. function message()
  2. {
  3. $m2 = '';
  4. $result = mysql_query("SELECT * FROM inventory WHERE count < 4");
  5. while($row = mysql_fetch_array($result))
  6. {
  7.  
  8. $m2 .= $row['item']. ": " .$row['count'] . "<br>";
  9. }
  10. return $m2;
  11. }
  12.  
  13.  
  14.  
  15. $to = "[email protected]";
  16. $subject = "My subject";
  17. $from = "[email protected]";
  18.  
  19.  
  20. $headers = "MIME-Version: 1.0" . "
  21. ";
  22. $headers .= "Content-type:text/html;charset=iso-8859-1" . "
  23. ";
  24.  
  25. $headers .= "From: $from";
  26. $message = message();
  27. mail($to,$subject,$message,$headers);
  28. echo "Mail Sent.";

Report this snippet  

You need to login to post a comment.