Jump to content

display end of week for set year and submit to database


nerrad

Recommended Posts

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>

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";
?>

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

<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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.