I am trying to create a 7 day task calendar using PHP – The dates at this moment are not linked with the MYSQL Database – that’s not my problem.
My current calendar only let you see tasks coming (those in future – today, tomorrow) but not in the past (yesterdays, last weeks) – which is how I like it.
Now , my problem being is , although my code is working successfully, it is slow at echo’ing and so I am looking for a quicker way to gain the same results using PHP.
<?
$day_count = 0;
$date= time();
$month = date('m', $date);
$year = date('Y', $date);
$days_in_month = cal_days_in_month(0, $month, $year) ;
$day_num = date("j", $date);
while ($day_num <= $days_in_month) {
while ( $day_count >=0 && $day_count <=7) {
?>
<div class="day"> <? echo $day_num; ?> </div>
<?
$day_num++;
$day_count++;
}
}
?>
Is this the real code?
If it is, you can speed it up by getting rid of the outer loop. At the moment that loop does not do anything as it is
truethe first time and then the inner loop only runs once as you don’t reset$day_countanywhere.