boney alex Posted April 19, 2007 Share Posted April 19, 2007 Ive found a simple calendar that displays all the days of the month as a link. I have saved the code below as eventcalendar.php and what I would like is when the user selects a certain day, that will take them to a page saved as eventinfo.php with the events for that day. I have managed to point each link to eventinfo.php, I'm just struggling to pass the actual date to that page, any ideas?? <?php mk_drawCalendar($_GET['m'],$_GET['y']); ?> </blockquote> </body> </html> <?php //********************************************************* // DRAW CALENDAR //********************************************************* function mk_drawCalendar($m,$y) { if ((!$m) || (!$y)) { $m = date("m",mktime()); $y = date("Y",mktime()); } /*== get what weekday the first is on ==*/ $tmpd = getdate(mktime(0,0,0,$m,1,$y)); $month = $tmpd["month"]; $firstwday= $tmpd["wday"]; $lastday = mk_getLastDayofMonth($m,$y); ?> <table cellpadding="2" cellspacing="0" border="1"> <tr><td colspan="7" bgcolor="#CCCCDD"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr><th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><<</a></th> <th><font size=2><?="$month $y"?></font></th> <th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>">>></a></th> </tr></table> </td></tr> <tr><th width=22 class="tcell">Su</th><th width=22 class="tcell">M</th> <th width=22 class="tcell">T </th><th width=22 class="tcell">W</th> <th width=22 class="tcell">Th</th><th width=22 class="tcell">F</th> <th width=22 class="tcell">Sa</th></tr> <?php $d = 1; $wday = $firstwday; $firstweek = true; /*== loop through all the days of the month ==*/ while ( $d <= $lastday) { /*== set up blank days for first week ==*/ if ($firstweek) { echo "<tr>"; for ($i=1; $i<=$firstwday; $i++) { echo "<td><font size=2> </font></td>"; } $firstweek = false; } /*== Sunday start week with <tr> ==*/ if ($wday==0) { echo "<tr>"; } /*== check for event ==*/ echo "<td class='tcell'>"; echo "<a href=\"eventinfo.php\" onClick=\"eventdate.value='$d-$m-$y';\">$d</a>"; echo "</td>\n"; /*== Saturday end week with </tr> ==*/ if ($wday==6) { echo "</tr>\n"; } $wday++; $wday = $wday % 7; $d++; } ?> </tr></table> Click on a date to select it and to populate the event date field on the left <br /> <?php /*== end drawCalendar function ==*/ } /*== get the last day of the month ==*/ function mk_getLastDayofMonth($mon,$year) { for ($tday=28; $tday <= 31; $tday++) { $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); if ($tdate["mon"] != $mon) { break; } } $tday--; return $tday; } ?> I think that the problem lies somewhere around this line: echo "<a href=\"eventinfo.php\" onClick=\"eventdate.value='$d-$m-$y';\">$d</a>"; Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/ Share on other sites More sharing options...
Lumio Posted April 19, 2007 Share Posted April 19, 2007 echo "<a href=\"eventinfo.php?date=$d-$m-$y\" onClick=\"eventdate.value='$d-$m-$y';\">$d</a>"; Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/#findComment-233448 Share on other sites More sharing options...
boney alex Posted April 19, 2007 Author Share Posted April 19, 2007 Cheers, works great Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/#findComment-233454 Share on other sites More sharing options...
boney alex Posted April 19, 2007 Author Share Posted April 19, 2007 Does anyone know how to highlight the current date in my calendar code? Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/#findComment-233491 Share on other sites More sharing options...
Lumio Posted April 20, 2007 Share Posted April 20, 2007 Yes I know, but I think you have to understand what your script does and then you know it and can do it on your own. Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/#findComment-233802 Share on other sites More sharing options...
genericnumber1 Posted April 20, 2007 Share Posted April 20, 2007 Yes I know, but I think you have to understand what your script does and then you know it and can do it on your own. I love you Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/#findComment-233808 Share on other sites More sharing options...
Lumio Posted April 20, 2007 Share Posted April 20, 2007 Link to comment https://forums.phpfreaks.com/topic/47783-calendar-how-do-i-do-this/#findComment-233812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.