nerrad Posted August 13, 2007 Share Posted August 13, 2007 Hi again people!, How do i go about displaying the week ending for each year in a drop down box? This is what i have found for the year but i cant seem to find or do a piece of code that displays the week ending. <select name="year" id="year" onChange="MM_jumpMenu('parent',this,0)"> <? for ($i = 2000; $i <= 2010; $i++) { IF($i == $_GET['year']){ $selected = "selected"; } ELSE { $selected = ""; } echo "<option value=\"summary.php?month=$_GET[month]&year=$i\" $selected>$i</option>\n"; } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/64680-display-end-of-week-for-set-year-and-submit-to-database/ Share on other sites More sharing options...
micah1701 Posted August 13, 2007 Share Posted August 13, 2007 Not sure what you mean by "week ending" you can find the last day of a given year: <?php $year = 2007; $lastDay = date("l",strtotime("12/31/$year")); // returns: "Monday" ?> the last "week" of the year, literally would be: <?php $year = 2007; echo "last week: 12/25/$year thru 12/31/$year"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/64680-display-end-of-week-for-set-year-and-submit-to-database/#findComment-322540 Share on other sites More sharing options...
nerrad Posted August 13, 2007 Author Share Posted August 13, 2007 Sorry i should have made myself a little more clear, What i need is to be able to loop through each end of week for an entire year for each year e.g this week ending will be 19/08/07 and the next will be 26/08/07 where as the same time next year the week ending will be 17/08/08 i need these to be displayed in a drop down box according to what year is selected in a drop down box. After this is accomplished i then need to be able retrieve info from the database for the last 7 days up untill the week ending that is submitted from the form. The data is stored in the database as event_day event_month event_year and as "int"s. event_day being day of the month e.g. 13, event_month the month etc Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/64680-display-end-of-week-for-set-year-and-submit-to-database/#findComment-322574 Share on other sites More sharing options...
micah1701 Posted August 13, 2007 Share Posted August 13, 2007 <select> <?php $thisWeek = date("d/m/Y", strtotime("19/08/07")); for($i=0; $i<52; $i++){ $calcDate = date("d/m/Y", strtotime("+$i week",strtotime($thisWeek))); ?> <option value="<?=$calcDate ?>"><?=$calcDate ?> </option> <?php } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/64680-display-end-of-week-for-set-year-and-submit-to-database/#findComment-322751 Share on other sites More sharing options...
nerrad Posted August 13, 2007 Author Share Posted August 13, 2007 thanks micah that did work apart from it only shows dates from 1969 - 1970 ??? and doesnt seem to take notice of the start date What needs to be changed? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/64680-display-end-of-week-for-set-year-and-submit-to-database/#findComment-322866 Share on other sites More sharing options...
micah1701 Posted August 13, 2007 Share Posted August 13, 2007 my bad, i didn't test. change: $thisWeek = date("d/m/Y", strtotime("19/08/07")); to: $thisWeek = date("Y/m/d", strtotime("2007/8/19")); note the format of Year/Month/Date works, but not Day/Month/Year Quote Link to comment https://forums.phpfreaks.com/topic/64680-display-end-of-week-for-set-year-and-submit-to-database/#findComment-322899 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.