scarface83 Posted March 10, 2007 Share Posted March 10, 2007 Hi, for some reason since i have changed this code , the days after the 10th on all months and the whole of januarys the links when you click all equal the same date , i have been looking at the code for hours and cant see where im going wrong , can anyone help <title>Absence Management Calendar</title> <?php session_start(); $set_team = $_POST['teams']; // grabs selected type of absence input from select_ absence form $set_advisor = $_POST['advisors']; // grabs the selected date ?> <?php $num_columns_displayed = 3; // How many months across to display? //echo ($row['colour']); // // // layout format variables !!!! // $month_table_header = "\n<table border=0 cellspacing=8>"; $month_row_header = "\n<tr>"; $month_td_tag = "<td valign=top>"; $cal_table_tag = "\n<table width=100 border=0 bgcolor=#DDDDDD>"; $cal_mon_tr_tag = "\n<tr bgcolor=#D3DCE3>"; $cal_dayname_tr_tag = "\n<tr bgcolor=#CCCCCC>"; $cal_day_tr_tag = "\n<tr>"; $cal_day_opentd = "<td align=center>"; $cal_day_closetd = "</td>"; //$cal_event_opentd = "<td align=center bgcolor=$colour><b>"; // added in the variable colour //$cal_event_opentd = "<td align=\"center\" bgcolor=\"".$row["colour"]."\"><b>"; $cal_event_closetd = "</b></td>"; // // Function fixlen($string) adds a zero to the front of the string if the // string length does not equal 2 // function fixlen($fixit) { if (strlen($fixit)<2) { return "0$fixit"; } else { return $fixit; } } // // Function generate_calender($year) will generate a calendar for the the current year // function generate_calender($year) { global $num_columns_displayed,$month_table_header,$month_row_header,$month_td_tag; $num_of_months = 12; $count_up = 1; echo $month_table_header; while ($count_up<=$num_of_months) { echo $month_row_header; $num_columns = $num_columns_displayed; while (($num_columns>0) && ($count_up<=$num_of_months)) { echo $month_td_tag; echo gen_month($year,$count_up); echo "</td>"; $count_up++; $num_columns--; } echo "</tr>"; } echo "\n</table>"; } // // Function gen_month($year,$month) will generate a month for // the year and month given. // function gen_month($year,$month) { global $cal_table_tag,$cal_mon_tr_tag,$cal_dayname_tr_tag,$cal_day_tr_tag; global $cal_event_opentd, $cal_event_closetd; global $cal_day_opentd, $cal_day_closetd; $mon_date = getdate(mktime(0,0,0,$month,1,$year)); $mon_name = $mon_date[month]; $mon_total_days = strftime( "%d",mktime(0,0,0,$month+1,0,$year)); echo $cal_table_tag; echo $cal_mon_tr_tag . "<td colspan=7 align=center><b>$mon_name $year</b></td></tr>"; echo $cal_dayname_tr_tag . "<td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr>"; $day_count = 1; while ($day_count<=($mon_total_days-7)) { $fweek = getdate(mktime(0,0,0,$month,$day_count,$year)); if ($day_count<=7) { $sb_cnt_td = $fweek[wday]; $sb_cnt = $fweek[wday]; $sb_max = 7; $p_line = $cal_day_tr_tag; while ($sb_cnt_td>=1) { $p_line .= "\n<td> </td>"; $sb_cnt_td--; } while ($sb_cnt<$sb_max) { $find_data = $fweek[year]. "/" .fixlen($fweek[mon]). "/" . fixlen($day_count) ; // this is the part the detimines what order to display the date , day, month , year $urldisp = gen_day_url($find_data,$day_count); #1# $test_date="$year-$month-$day_count"; $cal_query = "SELECT tbl_colour.colour FROM tbl_colour,absence_mgt WHERE tbl_colour.value=absence_mgt.abs_value AND absence_mgt.datestamp='$test_date' "; $result = mysql_query($cal_query); // runs the above query $row = mysql_fetch_array($result); $cal_event_opentd = "<td align=\"center\" bgcolor=\"".$row["colour"]."\"><b>"; if (strlen($urldisp) > 2) $p_line .= $cal_event_opentd . $urldisp . $cal_event_closetd; else $p_line .= $cal_day_opentd . $urldisp . $cal_day_closetd; $sb_cnt++; $day_count++; } echo "$p_line</tr>"; } else { $weekday_count = 1; $p_line = $cal_day_tr_tag; while ($weekday_count<=7) { $urldisp = gen_day_url($find_data,$day_count); #2# $test_date="$year-$month-$day_count"; $cal_query = "SELECT tbl_colour.colour FROM tbl_colour,absence_mgt WHERE tbl_colour.value=absence_mgt.abs_value AND absence_mgt.datestamp='$test_date' "; $result = mysql_query($cal_query); // runs the above query $row = mysql_fetch_array($result); $cal_event_opentd = "<td align=\"center\" bgcolor=\"".$row["colour"]."\"><b>"; if (strlen($urldisp) > 2) $p_line .= $cal_event_opentd . $urldisp . $cal_event_closetd; else $p_line .= $cal_day_opentd . $urldisp . $cal_day_closetd; $weekday_count++; $day_count++; } $p_line .= "</tr>"; echo $p_line; } } $sb_cnt_td = 7-($mon_total_days - $day_count); $p_line = $cal_day_tr_tag; while ($day_count<=$mon_total_days) { require('db_connect.inc'); // this includes the sql database connections details #3# $test_date="$year-$month-$day_count"; $cal_query = "SELECT tbl_colour.colour FROM tbl_colour,absence_mgt WHERE tbl_colour.value=absence_mgt.abs_value AND absence_mgt.datestamp='$test_date' "; $result = mysql_query($cal_query); // runs the above query $row = mysql_fetch_array($result); $cal_event_opentd = "<td align=\"center\" bgcolor=\"".$row["colour"]."\"><b>"; $urldisp = gen_day_url($find_data,$day_count); if (strlen($urldisp) > 2) $p_line .= $cal_event_opentd . $urldisp . $cal_event_closetd; else $p_line .= $cal_day_opentd . $urldisp . $cal_day_closetd; $day_count++; } while ($sb_cnt_td>1) { $p_line .= "\n<td> </td>"; $sb_cnt_td--; } echo "$p_line</tr>"; echo "</table>"; } function gen_day_url($data,$day) { if ( $row["colour"] == "# ) { echo " "; } else { } return "<a href=\"select_absence.php3?date=$data\">$day </a>"; } mysql_close(); ?> <div> <table width="1383" border="0"> <tr> <td width="1295"> <u>Absence Management Calendar</u></td> <td width="78"> <div align="right"><a href="main.php">Back</a> </div></td> </tr> </table> </div> <table width="998" height="100" border="0"> <tr> <td width="488"> <? // Here is the call for the calendar $year =date (Y); generate_calender($year); ?> </td> <td width="500"> </td> </tr> </table> <table width="775" border="0"> <tr> <td width="769"><a href="cal_legend.php" target="_blank">Click Here to View the Calendars Legend</a> </td> </tr> </table> <? echo $set_team, $set_advisor ; // just a test ?> Link to comment https://forums.phpfreaks.com/topic/42146-solved-calendar-help-part-2/ Share on other sites More sharing options...
scarface83 Posted March 10, 2007 Author Share Posted March 10, 2007 anyone ?? Link to comment https://forums.phpfreaks.com/topic/42146-solved-calendar-help-part-2/#findComment-204540 Share on other sites More sharing options...
scarface83 Posted March 11, 2007 Author Share Posted March 11, 2007 sorry to keep asking but can anyone help ? Link to comment https://forums.phpfreaks.com/topic/42146-solved-calendar-help-part-2/#findComment-204729 Share on other sites More sharing options...
scarface83 Posted March 11, 2007 Author Share Posted March 11, 2007 ok so its somewere in the function gen_month - after every full week its stops incrementing , can anyone see where im going wrong ? Link to comment https://forums.phpfreaks.com/topic/42146-solved-calendar-help-part-2/#findComment-204842 Share on other sites More sharing options...
scarface83 Posted March 11, 2007 Author Share Posted March 11, 2007 resolved this by adding $find_data = $fweek[year]. "/" .fixlen($fweek[mon]). "/" . Link to comment https://forums.phpfreaks.com/topic/42146-solved-calendar-help-part-2/#findComment-204894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.