title: How do I loop in PHP and get multiple rows returned from MySQL database?
body: <p>I have made a log in system which asks for email activation. It all works fine. However, there is no real 'spam' protection. When the user creates an account, it inserts a row with the column 'activated' = 'NO'.</p>
  
  <p>I want to make it so that if the user hasn't activated their account with, let's say, 3 hours, it will delete the row from the MySQL database. I have made a cron job which runs the following every 30 mins.</p>
  
  <pre><code>&lt;?php
  
  ob_start();
  include 'global.php';
  ob_end_clean();
  
  $check_times = (time() - ('-3 hours'));
  $query = "SELECT * FROM users WHERE time&lt;=$check_times and activated='NO'";
  $result = mysql_query($query) or trigger_error(mysql_error().$query);
  $row = mysql_fetch_array($result, MYSQL_ASSOC);
  $inactive_user = $row['username'];
  
  echo $inactive_user;
  echo "&lt;br&gt;";
  echo $check_times;
  ?&gt;
  </code></pre>
  
  <p>The 'global.php' is connecting to the database. The above code works but only for one row (IT ONLY RETURNS THE VALUE OF THE FIRST INSTANCE IT COMES ACROSS)</p>
  
  <p>I have looked into 'Do While' and 'Loop Until' and whatever but don't know what to put in the brackets...Do While (//what do I put in here?)</p>
  
  <p>At the moment, the code only echos out the instances but I will change that to delete</p>