tara_irvine Posted April 24, 2008 Share Posted April 24, 2008 ok I'm in desperate need of help. I've developed this form that a user can enter family birthdays into a database, the code is along the lines of <?php $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December'); $days = range (1, 31); $years = range (1920, 2008); echo "<select name='day'>"; echo '<option>Day</option>\n'; foreach ($days as $value) { echo '<option value="'.$value.'">'.$value.'</option>\n'; } echo '</select><br />'; echo "<select name='month'>"; echo '<option>Month</option>\n'; foreach ($months as $value) { echo '<option value="'.$value.'">'.$value.'</option>\n'; } echo '</select><br />'; echo "<select name='year'>"; echo '<option>Year</option>\n'; foreach ($years as $value) { echo '<option value="'.$value.'">'.$value.'</option>\n'; } ?> my first question is how do I insert the value of these results into an array as a time code? The reason this is important is because I need stuff to come out of the database if the birthday is between todays date and one month 14 days time. This is so the user can see that say her brothers birthday is coming up. $todays_date = strtotime("today 00:00:00",time()); $target_date = strtotime("-1 month 14 days 00:00:00",time()); $MySQLquery = "SELECT * from hobby WHERE username = '$sessionuname' && `date` <= $todays_date && `date` >= $target_date"; Firstly does this make sense? and secondly since PHP is my vice will it work? Thanks so much for any help xo Quote Link to comment Share on other sites More sharing options...
fenway Posted April 24, 2008 Share Posted April 24, 2008 There are many examples of sql birthday logic on the mysql refman page on date/time functions. 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.