jwk811 Posted May 16, 2009 Share Posted May 16, 2009 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 Quote Link to comment Share on other sites More sharing options...
Masna Posted May 16, 2009 Share Posted May 16, 2009 Might I suggest using UNIX timestamps instead of MySQL DATETIME format. $yesterday = time() + (60*60*24); Quote Link to comment Share on other sites More sharing options...
jwk811 Posted May 16, 2009 Author Share Posted May 16, 2009 how would that be yesterday? Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 17, 2009 Share Posted May 17, 2009 He travels very quickly. try subtracting. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.