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? Quote Link to comment 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')) Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. 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.