I have checked your code and the last piece of php code at the end of the script should look something like below. Notice how I added $date=0 and $date+=1. That is because the date you were saying that wasn't being displayed hadn't been assigned any value at all. So try using the below code.
foreach ($week as $key => $val)
// here you may need to add $date+=1; or $date-=1;
echo '<td align="center">'. $date .'</td>';