dauzy Posted July 16, 2008 Share Posted July 16, 2008 Hello, I've haven't been a member to this forum for more then 24 hours and I've already got some greatly appreciated help. But, now its the time again for me to ask for help. I used this a resource...my code follows this technique rather closely with some modifications to include a dynamic background change. http://video.about.com/php/How-to-Create-a-PHP-Calendar.htm Scenario: So, I need to make a PHP calendar....Easy enough right...but there one problem. I'm able to make the a "full" calendar but I need to modify the calendar to skip sundays... This means that all Sundays are excluded when making setting table. data. So... the calendar would look like this: July Monday Tuesday Wednesday Thursday Friday Saturday 1 2 3 4 5 7 8 9 10 11 12 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 30 31 Heres the php code that takes care of making the calendar.... //Create a varible directory, which holds information that is taken from the scan() funtion. $directory = scan(); //Variables for the day, month and year $date = time (); $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date); //Finds the first day of the month $first_day = mktime(0,0,0,$month, 1, $year); //Calculates the day of the week that the first day is on $day_of_week = date('D', $first_day); //Sets the the day to a numerical value... Sun = 0...Sat = 6 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; } //Calculates the days in the month $days_in_month = cal_days_in_month(0, $month, $year); $day_count = 1; //This while loop creates the blank spaces before the first day of the month. while($blank > 0) { echo "<td></td>"; $blank = $blank-1; $day_count++; } $day_num = 1; //This while loop is used to create a table row and table ddta. while($day_num <= $days_in_month) { //If the $day_num is included in $directory new table data with corresponded .jpg will be used. if(in_array($day_num, $directory)) { $event = "images/_calendar/July/calendar/".$day_num.".jpg"; echo '<td width="145px" height="145px" background="'.$event.'">'.$day_num.'</td>'; $day_num++; $day_count++; } else { //If $day_num is not included in $directory new table data will be displayed with the default.jpg echo '<td width="145px" height="145px" background="images/_calendar/July/calendar/default.jpg">'.$day_num.'</td>'; $day_num++; $day_count++; } //This will ensure table row in the calendar will only have 7 days to it. if($day_count > 7) { echo "</tr><tr>"; $day_count = 1; } } //This will ensure table row in the calendar will only have 7 days to it. while($day_count > 1 && $day_count <= 7) { echo "<td></td>"; $day_count++; } Thanks, Dauzy Quote Link to comment Share on other sites More sharing options...
dauzy Posted July 16, 2008 Author Share Posted July 16, 2008 Sorry about double post >.< Accidentally pressed the "enter" button and some how last post got posted without me knowing. Quote Link to comment 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.