title: CRON Job Send email to users in DB?
body: <p>If I've got a database of users that have filled out a form, can I use a cron job to send an automated email? If so, what is the best way to "loop" it so that it sends the email once to each user?</p>
  
  <pre><code>$data = mysql_query("
  SELECT *
  FROM completed
  WHERE
  followupsent='0000-00-00 00:00:00'
  AND valuesent + INTERVAL 4 DAY &lt;= NOW()
  ")
  or die(mysql_error()); 
  
  while($info = mysql_fetch_array( $data )) 
  {
  }
  </code></pre>
  
  <p>This checks to see if "followupsent" has been updated already as it updates with <code>NOW()</code> when it sends and also checks to see how many days since the value was sent.</p>
  
  <p>I'm worried that by putting the email sending information in the while tags is going to loop for each row and end up sending a ton of emails.</p>
  
  <p>Would using and <code>if</code> instead of a <code>while</code>:</p>
  
  <pre><code>if($info = mysql_fetch_array( $data )) 
  {
  }
  </code></pre>
  
  <p>In order to send out to the first in the database and then let the cron job handle the rest by checking every minute which one is next?</p>