hedonomania Posted January 23, 2014 Share Posted January 23, 2014 There is sth wrong with my code. I am trying to program simple table that will display the days of the month. The internet explorer keeps on loading the page but without any output... Thanks in advance! <?phpdate_default_timezone_set ('Europe/Warsaw');//11print "Today is:<br/>";print date ('jS F Y l G:i a');//14?></head><body><?php//20 creating date variables$month=date('n');$year=date('Y');$day=date('j');$previous_year=$year--;$next_year=$year++;$previous_month=$month--;$next_month=$month++; //32 what day of the week is the first day of the month$first_day=mktime(0,0,0,$month,1,$year);$day_of_week=date('D',$first_day); print "<table border=1 width=358>";print "<tr> $month $year </tr>";print "<tr><td><td width=50>Monday</td>";print "<td><td width=50>Tuesday</td>";print "<td><td width=50>Wednesday</td>";print "<td><td width=50>Thursday</td>";print "<td><td width=50>Friday</td>";print "<td><td width=50>Saturday</td>";print "<td><td width=50>Sunday</td></tr>";//blank days in calendar table$day_of_week = date('D', $first_day);switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; }//setting the day count at 1$day_count=1;print "<tr>";//62 while loop to generate first blank days and than all days in the monthwhile ( $blank >0 ) { print "<td></td>"; $blank=$blank-1; $day_count++; } $days_in_month=cal_days_in_month(0,$month,$year);$day_number=1; //77 while loop to generate the days of the month while ($day_number<=$days_in_month) { print "<td> $day_number </td>"; $day_number++; $day_count++; //84 new week starting at new row if($day_count>7) { print "<tr></tr>"; $day_count=1; } } //91 blank days for not filled days at the end of monthwhile ( $day_count>1 AND $daycount<=7) { print "<td></td>"; $day_count++; } //96 end of the calendar tableprint "</tr></table>"; ?></body></html> Link to comment https://forums.phpfreaks.com/topic/285620-php-calendar/ Share on other sites More sharing options...
Ch0cu3r Posted January 23, 2014 Share Posted January 23, 2014 Tested your code and one of your while loops is causing an infinity loop and so no output is ever sent. Have a look at Barands code here for producing a calendar in PHP. http://forums.phpfreaks.com/topic/285347-custom-php-calendar-integer-to-month-string/?do=findComment&comment=1465171 Link to comment https://forums.phpfreaks.com/topic/285620-php-calendar/#findComment-1466328 Share on other sites More sharing options...
Ch0cu3r Posted January 23, 2014 Share Posted January 23, 2014 I found the problem. On line 91 you left off the underscore in $day_count while ( $day_count>1 AND $daycount<=7) { // ^ no underscore Link to comment https://forums.phpfreaks.com/topic/285620-php-calendar/#findComment-1466331 Share on other sites More sharing options...
hedonomania Posted January 23, 2014 Author Share Posted January 23, 2014 thanks a lot! Link to comment https://forums.phpfreaks.com/topic/285620-php-calendar/#findComment-1466334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.