deansaddigh Posted January 7, 2010 Share Posted January 7, 2010 so i can then pass the value into a query and bring back results based on the year they wanted? Quote Link to comment https://forums.phpfreaks.com/topic/187571-how-can-i-fill-a-select-box-with-years-that-have-passed-and-years-to-come/ Share on other sites More sharing options...
Adam Posted January 7, 2010 Share Posted January 7, 2010 Well many ways to do it. I'm guessing populating the list you should be able to manage? What data type are you using for your date field? Quote Link to comment https://forums.phpfreaks.com/topic/187571-how-can-i-fill-a-select-box-with-years-that-have-passed-and-years-to-come/#findComment-990310 Share on other sites More sharing options...
deansaddigh Posted January 7, 2010 Author Share Posted January 7, 2010 Sorry i have more info, i have to fill the box with years that have posts etc the date format is a string so it loks like this 20090219 for 2009-02-19 Quote Link to comment https://forums.phpfreaks.com/topic/187571-how-can-i-fill-a-select-box-with-years-that-have-passed-and-years-to-come/#findComment-990327 Share on other sites More sharing options...
Adam Posted January 7, 2010 Share Posted January 7, 2010 This will give you a list of the years... <select name="year"> <?php $cur_year = date("Y"); for ($i = ($cur_year-10); $i <= ($cur_year+10); $i++) { echo '<option value="'.$i.'">'.$i.'</option>'; } ?> </select> Do you need help with the querying side of things too? Quote Link to comment https://forums.phpfreaks.com/topic/187571-how-can-i-fill-a-select-box-with-years-that-have-passed-and-years-to-come/#findComment-990359 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.