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? 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? 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 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? 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
Archived
This topic is now archived and is closed to further replies.