I am using a script provided to generate a weekly calendar. What I am looking to do though is allow the user to specify which day of the week the calendar starts on. So to have a variable that holds the day the week should start on and then be able to scroll through each week starting from this day.
Here is a very basic example of what I have:
<?php
$dt = new DateTime;
if (isset($_GET['year']) && isset($_GET['week'])){
$dt->setISODate($_GET['year'], $_GET['week']);
}else{
$dt->setISODate($dt->format('o'), $dt->format('W'));
}
$year = $dt->format('o');
$week = $dt->format('W');
?>
<a onclick="location.href='<?php echo $_SERVER['PHP_SELF'].'?week='.($week-1).'&year='.$year; ?>'">Previous</a> <!--Previous week-->
<a onclick="location.href='<?php echo $_SERVER['PHP_SELF'].'?week='.($week+1).'&year='.$year; ?>'">Next Week</a> <!--Next week-->
<table>
<tr>
<td>Employee</td>
<?php
do{
echo "<td>" . $dt->format('l') . "<br>" . $dt->format('d M Y') . "</td>\n";
$dt->modify('+1 day');
}while ($week == $dt->format('W'));
?>
</tr>
</table>