Styles2304 Posted January 31, 2008 Share Posted January 31, 2008 <?php include "conn.inc.php"; //Checks to see if day, month, and year have been assigned in the url $day = $_GET["day"]; $month = $_GET["month"]; $year = $_GET["year"]; if ($day == "") $day = date("j"); if ($month == "") $month = date("m"); if ($year == "") $year = date("Y"); $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; $monthNext = $month + 1; $monthPrev = $month - 1; //Fixes monthNext and monthPrev to work with a 12 month calendar if ($monthNext == 13) { $monthNext = 1; $yearNext = $year + 1; } else { $yearNext = $year; } if ($monthPrev == 0) { $monthPrev = 12; $yearPrev = $year - 1; } else { $yearPrev = $year; } //Turns $EventDate into an array where the array is split up based on the days. For every array the value of 1 is entered to designate //an event on that day. $query = "SELECT EventDate FROM CalendarEvents WHERE ((MONTH(EventDate) = " . $month . ") && Validate = 1);"; $result = mysql_query($query, $link) or die(mysql_error()); $EventDate = array(); while ($row = mysql_fetch_array($result)) { $found = $row['EventDate']; $pieces = explode("-", $found); $ed = ($pieces[2]); if ($ed < 10) { $ed = intval($ed); $EventDate[$ed] = "1"; } else { $EventDate[$ed] = "1"; } } ?> <LINK REL=StyleSheet HREF="calendar.css" TYPE="text/css"> <table width='168' height="17" border='0' cellspacing='0' cellpadding='0'> <tr> <td colspan="7" class="title"> <font class="title"> <center> <?php echo '<a href="calendar.php?month=' . $monthPrev . '&year=' . $yearPrev . '" class="calendartitle"> << </a>'; echo $monthName; echo '<a href="calendar.php?month=' . $monthNext . '&year=' . $yearNext . '" class="calendartitle"> >> </a>'; ?> </center> </font> </td> </tr> <tr class="daylabels"> <td class='blank' width='24'>Sn</td> <td class='blank' width='24'>Mn</td> <td class='blank' width='24'>Tu</td> <td class='blank' width='24'>Wd</td> <td class='blank' width='24'>Th</td> <td class='blank' width='24'>Fr</td> <td class='blank' width='24'>St</td> </tr> </table> <table width='168' height="17" border='0' cellspacing='2' cellpadding='0'> <tr class="date"> <?php for ($i = 1; $i < $numDays + 1; $i++, $counter++) { $timeStamp = strtotime("$year-$month-$i"); if ($i == 1) { //Figures out when the first day of the month is $firstDay = date("w",$timeStamp); //Checks day of the week for first day. for($j = 0; $j < $firstDay; $j ++, $counter++) echo "<td width='24' height='16' class='blank'> </td>"; } if($counter % 7 == 0) { echo "</tr><tr class='date'>"; } if (($i == date("d") && $month == date("m") && $year == date("Y")) && ($EventDate[$i])) { echo "<td width='24' height='16' class='today'><a href='showevent.php?day=$i&month=$month&year=$year' class='calendar' target='_parent'>$i</a></td>"; } else { if ($i == date("d") && $month == date("m") && $year == date("Y")){ echo "<td width='24' height='16' class='today'>$i</td>"; } else { if ($EventDate[$i]) { echo "<td width='24' height='16' class='event'><a href='showevent.php?day=$i&month=$month&year=$year' class='calendar' target='_parent'>$i</a></td>"; } else { if (date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6) { echo "<td width='24' height='16' class='weekend'>$i</td>"; } else { echo "<td width='24' height='16' class='normal'>$i</td>"; } } } } } ?> </table> Check 'er out. I don't really understand why it would be acting this way. To see it in action: http://www.newcovenant-th.org/ and then click the right arrows on the mini-calendar. Something else worth noting . . . it seems to only display as march and with the incorrect amount of days towards the end of the january. Any ideas? As you can see, this is my Church's public website so any help in a timely manner would be GREATLY appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/ Share on other sites More sharing options...
Styles2304 Posted January 31, 2008 Author Share Posted January 31, 2008 Anyone? If it helps, I'm pretty sure the problem is in this area: <?php include "conn.inc.php"; //Checks to see if day, month, and year have been assigned in the url $day = $_GET["day"]; $month = $_GET["month"]; $year = $_GET["year"]; if ($day == "") $day = date("j"); if ($month == "") $month = date("m"); if ($year == "") $year = date("Y"); $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; $monthNext = $month + 1; $monthPrev = $month - 1; //Fixes monthNext and monthPrev to work with a 12 month calendar if ($monthNext == 13) { $monthNext = 1; $yearNext = $year + 1; } else { $yearNext = $year; } if ($monthPrev == 0) { $monthPrev = 12; $yearPrev = $year - 1; } else { $yearPrev = $year; } and: <?php echo '<a href="calendar.php?month=' . $monthPrev . '&year=' . $yearPrev . '" class="calendartitle"> << </a>'; echo $monthName; echo '<a href="calendar.php?month=' . $monthNext . '&year=' . $yearNext . '" class="calendartitle"> >> </a>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454078 Share on other sites More sharing options...
Styles2304 Posted January 31, 2008 Author Share Posted January 31, 2008 Anyone? Please? lol Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454212 Share on other sites More sharing options...
haku Posted January 31, 2008 Share Posted January 31, 2008 Try changing this: $currentTimeStamp = strtotime("$year-$month-$day"); To this: $currentTimeStamp = mktime(0,0,0,$month,$day,$year); I can't guarantee it will work, but I kind of suspect that your strtotime is causing the troubles. Since no one else is helping, I'm throwing this out as a suggestion, but with no guarantees of success. Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454279 Share on other sites More sharing options...
Styles2304 Posted January 31, 2008 Author Share Posted January 31, 2008 lol any input is good input. I'll try it out and let you know. Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454282 Share on other sites More sharing options...
Styles2304 Posted January 31, 2008 Author Share Posted January 31, 2008 Well, I appreciate the input . . . but it reacts the exact same way. Anyone else have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454287 Share on other sites More sharing options...
rajivgonsalves Posted January 31, 2008 Share Posted January 31, 2008 it should be $currentTimeStamp = strtotime("$year-$month-01"); actually today is 31 so your giving a input as 2008-2-31 and feb does not have a 31 same for the other months Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454305 Share on other sites More sharing options...
Styles2304 Posted January 31, 2008 Author Share Posted January 31, 2008 Ah . . . ok . . .so I guess that makes sense Thank you for pointing out the problem. I should be able to jerry-rig up a solution now. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454312 Share on other sites More sharing options...
rajivgonsalves Posted January 31, 2008 Share Posted January 31, 2008 change $currentTimeStamp = strtotime("$year-$month-$day"); to $currentTimeStamp = strtotime("$year-$month-01"); and it should work. Quote Link to comment https://forums.phpfreaks.com/topic/88658-solved-february-displays-as-march/#findComment-454316 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.