Return to Snippet

Revision: 7741
at March 12, 2009 12:42 by benphelps


Updated Code
<?php
  set_time_limit(0);// this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  mysql_connect("localhost", "root", "pass");
  mysql_select_db("database");
  $query = mysql_query("SELECT email FROM account");
  $emailsubject = "This is a sample subject!";
  $emailbody = file_get_contents("email.html");
  $fromaddress = "[email protected]";
  
  
  // here we loop through the mysql array until we reach then end
  while ($row = mysql_fetch_array($query, MYSQL_NUM))
  	{// start while
      
      // we use the sql var. $row and we use the field 0 to pickup the email address
      mail($row[0], $emailsubject, $emailbody, "From: " . $fromaddress . "\nX-Mailer: PHP 4.x");
	  
	}// end while

?>

Revision: 7740
at August 10, 2008 16:17 by benphelps


Initial Code
<?php
  set_time_limit(0);// this will keep the script from stoping if it takes longer then 30 seconds, must have this here
  mysql_connect("localhost", "root", "pass");
  mysql_select_db("database");
  $query = mysql_query("SELECT email FROM account");
  $emailsubject = "This is a sample subject!";
  $emailbody = file_get_contents("email.html");
  $fromaddress = "[email protected]";
  
  
  // here we loop through the mysql arrat untill we reach then end
  while ($row = mysql_fetch_array($query, MYSQL_NUM))
  	{// start while
      
      // we use the sql var. $row and we use the field 0 to pickup the email address
      mail($row[0], $emailsubject, $emailbody, "From: " . $fromaddress . "\nX-Mailer: PHP 4.x");
	  
	}// end while

?>

Initial URL
http://phelps.impactwow.com

Initial Description

                                

Initial Title
Loop email reading MySQL

Initial Tags
email, mysql

Initial Language
PHP