jpergega Posted March 20, 2014 Share Posted March 20, 2014 Hi I have a alert box here that want to pop up when a user is logged into their account. The alert box will tell the user there is a expired task. Here is my code but is not doing anything please could you tell me what is wrong with it? because is not showing any errors. Thanks <?php if(isset($_SESSION['account_id'])) { $account_id = $_SESSION['account_id']; $curdate = date('yyyy/mm/dd'); $query4 = "select finish from task WHERE account_id=$account_id"; $result4= mysqli_query($con,$query4); while($row = mysqli_fetch_array($result4)){ if($row['finish'] == $curdate) { echo '<script language="javascript">alert("Your task had been expired.")</script>'; } } } ?> Link to comment Share on other sites More sharing options...
Ingolme Posted March 20, 2014 Share Posted March 20, 2014 You should read the documentation on PHP's date() function. As you have it written right now today's date would be represented as 14141414/0303/2020 Link to comment Share on other sites More sharing options...
jpergega Posted March 20, 2014 Author Share Posted March 20, 2014 You should read the documentation on PHP's date() function. As you have it written right now today's date would be represented as 14141414/0303/2020 Thanks I read the date function link you provided and I have changed the date format but still nothing happened. Any other suggestions that I am doing wrong? Link to comment Share on other sites More sharing options...
thescientist Posted March 20, 2014 Share Posted March 20, 2014 where's the code you changed? We can't tell what you did wrong without it. Are you checking the values of $curdate and $row['finish']? Do you know what they actually are so you can tell if they should or shouldn't be equal? Link to comment Share on other sites More sharing options...
jpergega Posted March 20, 2014 Author Share Posted March 20, 2014 where's the code you changed? We can't tell what you did wrong without it. Are you checking the values of $curdate and $row['finish']? Do you know what they actually are so you can tell if they should or shouldn't be equal? Earlier I changed to this $today = date("Y-m-d H:i:s"); Now I have got rid of the time $today = date("Y-m-d"); is working now Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted March 20, 2014 Share Posted March 20, 2014 Just consider this: if the finish date is yesterday then your code is not going to show a message. Link to comment Share on other sites More sharing options...
jpergega Posted March 23, 2014 Author Share Posted March 23, 2014 Just consider this: if the finish date is yesterday then your code is not going to show a message. Thank you I did change the operator to if($row['finish'] <= $curdate) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now