Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Info About Previous Month

    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"].'';
          }
       } 

  • #2
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    PHP Code:
    $last_month date('Y-m'strtotime('last month'));
    $result mysql_query("SELECT * FROM table WHERE CONCAT(YEAR(loginDateTime), '-', MONTH(loginDateTime)) = '$last_month'") or exit(mysql_error()); 
    Last edited by devinemke; 04-02-2007 at 03:34 PM.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I received this error any ideas?

    Code:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in e:\emailMembersLogin.php on line 18
    There are no members who have logged in this monthPHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in e:\emailMembersLogin.php on line 18

  • #4
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    what does mysql_error have to say about your query?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •