PHP List the days of this week in a table that can be changed to show next week or last week with a button
<p>I am trying to get a calendar up and running.  Even though I'm not that great with PHP I managed to get a monthly view calendar up and running quite nicely.  However, the goal posts have been moved somewhat and the powers that be would like a weekly view calendar.  When they open it will show all of the days of the current week in a table and then have the option to go forward a week and show the next week or back a week.  I have struggled with this for many days and my code has gotten over complicated and messy when I am sure there must be a simple solution.</p>

<p>I know that this is a big ask but I will be so grateful if someone could point me in the right direction or give me a simple script for me to build on so I can get back to living my life</p>

<p>This is what I have so far</p>

<pre><code>$week_number = date("W");
$year = date("Y");

if($week_number &lt; 10){
   $week_number = "0".$week_number;
}

for($day=0; $day&lt;=6; $day++)
{
  echo date('d-m-Y', strtotime($year."W".$week_number.$day))." | \n";
}
?&gt;
</code></pre>

<p>I managed to get it up and running in a fashion by adding 1 to the $week_number if the 'next_week' button and been clicked (part of a self posting form I haven't included to keep the script simple ) which worked well until the year changed because the week numbers carried on past 53 and I haven't added a way to make $year increase or decrease  That's where it all went wrong</p>
