I'm setting up a page that will tell me each month what members have logged in... But I want to run it on the 1st of the month and view the previous months results, at the moment I have only been able to work out how to get it to run for the current month... Any ideas?

PHP Code:
$year date('Y');
$month date('m');

$results mysql_query("SELECT * FROM `table` WHERE `loginDateTime` LIKE '%$month%'");

if (
mysql_num_rows($results) < 1) {
die(
'There are no members who have logged in this month');
}

else {

  while (
$qry mysql_fetch_array($results)) {
      if (
strtotime($qry['loginDateTime']) <= (time() + 86400*31)) {
         
$login .= 'Name: '.$qry["FirstName"].' '.$qry["LastName"].' ('.$qry["DateOfBirth"].') '.$qry["Email"].'\r\n';
      }
  }
  
  while (
$qry mysql_fetch_array($results)) {
      if (
strtotime($qry['loginDateTime']) <= (time() + 86400*31)) {
         
$login .= 'Name: '.$qry["FirstName"].' '.$qry["LastName"].' ('.date("d-m-Y"strtotime($qry["DateOfBirth"])).') '.$qry["Email"].'';
      }
   }