TutorMe Posted September 27, 2007 Share Posted September 27, 2007 I have two variables stored in a database. They are "month," and "day." Currently, I type the "month" variable into the code manually, and update that each month. I then use a code to see if the "day" variable matches the day it is. This is the code: if ($row['day'] == date('d')) . I would like to make this code more automated by having it check both variables, but since the "month," and "day" variables are stored in two separate rows instead of together as "month/day," I am running into trouble. I have tried things like this: if ($row['month'] . '/' . $row['day'] == date('m/d')) $list = $row['username'] . " "; , but nothing seems to work. Does anybody have any ideas on how to do this? Link to comment https://forums.phpfreaks.com/topic/70974-solved-checking-two-separate-date-variables/ Share on other sites More sharing options...
Barand Posted September 27, 2007 Share Posted September 27, 2007 if ($row['month'] == date('n') && $row['day'] == date('j')) Link to comment https://forums.phpfreaks.com/topic/70974-solved-checking-two-separate-date-variables/#findComment-356843 Share on other sites More sharing options...
TutorMe Posted September 28, 2007 Author Share Posted September 28, 2007 if ($row['month'] == date('n') && $row['day'] == date('j')) Thanks, but why would you use "n" and "j"? Also, another problem I have run into is that the "month" variable is stored as "January, February, etc...." Since the date function returns a number, I am again stuck. Any ideas are appreciated. Thanks again. Link to comment https://forums.phpfreaks.com/topic/70974-solved-checking-two-separate-date-variables/#findComment-356865 Share on other sites More sharing options...
Barand Posted September 28, 2007 Share Posted September 28, 2007 n and j return numbers without the preceding 0 Use date('F') to match against January etc Link to comment https://forums.phpfreaks.com/topic/70974-solved-checking-two-separate-date-variables/#findComment-356870 Share on other sites More sharing options...
TutorMe Posted September 28, 2007 Author Share Posted September 28, 2007 Ok. Thank you very much. This is what I was looking for. Link to comment https://forums.phpfreaks.com/topic/70974-solved-checking-two-separate-date-variables/#findComment-356884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.