Jump to content

login days in a row


jwk811

Recommended Posts

this is driving me crazy. what im trying to see if count how many days a user logs in in a row.

 

the first part works where it checks to see if they logged in yesterday if yes it adds to the login days. if no it checks to see if its been longer than yesterday in that case it would go back to 0. if they are logging in again that day it wont do anything.

 

$yesterday  = date('Y-m-d 00:00:00', strtotime('-1 day'));
$yesterday2 = date('Y-m-d 23:59:59', strtotime('-1 day'));

$sql = "SELECT user_last_login FROM tbl_user
        WHERE user_id = '{$row['user_id']}' AND user_last_login >= '$yesterday' AND user_last_login <= '$yesterday2'";
$result = dbQuery($sql);

if(dbNumRows($result) == 1){

            $sql = "UPDATE tbl_user 
                    SET user_daily = user_daily + 1
                    WHERE user_id = '{$row['user_id']}'";
            dbQuery($sql);
}
else{

$sql = "SELECT * FROM tbl_user
        WHERE user_id = '{$row['user_id']}' AND user_last_login > '$yesterday'";
$result = dbQuery($sql);


	if(dbNumRows($result) == 1){

           		 $sql = "UPDATE tbl_user 
            	        SET user_daily = 1
             	   	    WHERE user_id = '{$row['user_id']}'";
           		 dbQuery($sql);

	}
}

 

$sql = "SELECT * FROM tbl_user

        WHERE user_id = '{$row['user_id']}' AND user_last_login > '$yesterday'";

$result = dbQuery($sql);

 

 

if(dbNumRows($result) == 1){

 

^^ that part isnt working. for some reason its not getting that its been longer than yesterday and ive changed it to over a week since last login and it wont do it. its not getting any rows its not a problem with the update. please help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.