blueman378 Posted March 2, 2008 Share Posted March 2, 2008 hi guys well i have this code for a calender: <?php //Here is Step 1. $date =time () ; //Gets today’s date $day = date('d', $date) ; //gets the day $month = date('m', $date) ;//gets the month $year = date('Y', $date) ;//gets the year $firstDay = mktime(0,0,0,$month, 1, $year) ;//gets the first day of the month. $monthName = date('F', $firstDay) ; //gets the month name //Here is Step 2 $firstDayOfWeek = date('D', $firstDay) ; //gets the day of the week for the first of the month. // Here is Step 3 switch($firstDayOfWeek){ case "Sun": $spacer = 0; break; case "Mon": $spacer = 1; break; case "Tue": $spacer = 2; break; case "Wed": $spacer = 3; break; case "Thu": $spacer = 4; break; case "Fri": $spacer = 5; break; case "Sat": $spacer = 6; break; } //Here is Step 4 $daysInMonth = cal_days_in_month(0, $month, $year) ; //gets number of days in month //Here is Step 5 echo "<table border=2 width=350>"; //The next few lines set up the table and the day headers. echo "<tr><th colspan=7> $monthName $year </th></tr>"; echo "<tr><td width=50>S</td><td width=50>M</td><td width=50>T</td><td width=50>W</td><td width=50>T</td><td width=50>F</td><td width=50>S</td></tr>"; $dayCount = 1; //counts the number of days. We only want it to count up to 7. echo "<tr>"; while ( $spacer > 0 ) //Start with the blank days in the beginning of the month. { echo "<td></td>"; $spacer = $spacer-1; $dayCount++; } $dayNumber = 1; // first we must set a counter to so we can print out the days. while ( $dayNumber <= $daysInMonth ) //While loop will print out the days as long as there are days left in the month. { echo "<td> $dayNumber </td>"; $dayNumber++; $dayCount++; if ($dayCount > 7) //Makes sure we only print out seven days per week. { echo "</tr><tr>"; $dayCount = 1; } } while ( $dayCount >1 && $dayCount <=7 ) //We print blanks at the end of the month. { echo "<td> </td>"; $dayCount++; } echo "</tr></table>"; //End the table for the calendar. ?> now the problem is that the code is echoing itself after a certian point: output: "; //The next few lines set up the table and the day headers. echo " "; echo "SMTWTFS"; = 1; //counts the number of days. We only want it to count up to 7. echo ""; while ( > 0 ) //Start with the blank days in the beginning of the month. { echo ""; = -1; ++; } = 1; // first we must set a counter to so we can print out the days. while ( <= ) //While loop will print out the days as long as there are days left in the month. { echo " "; ++; ++; if ( > 7) //Makes sure we only print out seven days per week. { echo ""; = 1; } } while ( >1 && <=7 ) //We print blanks at the end of the month. { echo " "; ++; } echo ""; //End the table for the calendar. ?> now the thing is it is only doing this if i put it inside another page, if it is simply run by itself it works fine, code is attached as new restrictions will not allow me to post it for some reason cheers matt Quote Link to comment https://forums.phpfreaks.com/topic/93973-php-echiong-itself/ Share on other sites More sharing options...
sasa Posted March 2, 2008 Share Posted March 2, 2008 in line 171 you start <<<< EOPAGE close it in line 244 Quote Link to comment https://forums.phpfreaks.com/topic/93973-php-echiong-itself/#findComment-481487 Share on other sites More sharing options...
blueman378 Posted March 3, 2008 Author Share Posted March 3, 2008 thanks man, forgot all about EOPAGE, simply removed it all together and went back to closing my tags and it worked great Quote Link to comment https://forums.phpfreaks.com/topic/93973-php-echiong-itself/#findComment-482198 Share on other sites More sharing options...
Lamez Posted March 3, 2008 Share Posted March 3, 2008 ya I forget to do stupid stuff like that all the time. lol Quote Link to comment https://forums.phpfreaks.com/topic/93973-php-echiong-itself/#findComment-482200 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.