bob_the _builder Posted March 10, 2008 Share Posted March 10, 2008 Hi, I have the following script, but I cant make it highlight days that contain events or the current day in a different colour.. How would I go about adding such features? <form action="../calendar.php" method="get"> <table width="160" align="center" border="1" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#ffffff"> <tr> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Sun</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Mon</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Tue</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Wed</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Thu</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Fri</b></td> <td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Sat</b></td> </tr> '; $day = 1; $wday = $firstweekay; $firstweek = true; while ($day <= $lastday) { if($firstweek) { echo '<tr>'; for ($i=1; $i<=$firstweekay; $i++) { echo '<td></td>'; } $firstweek = false; } if ($wday==0) { echo '<tr>'; } if(intval($monthnum) < 10) { $newmonthnum = '0'.$monthnum.''; } elseif (intval($monthnum) >= 10) { $newmonthnum = $monthnum; } if(intval($day) < 10) { $newday = '0'.$day.''; } elseif(intval($day) >= 10) { $newday = $day; } $link_date = "$year-$newmonthnum-$newday"; if($day == $day){ $color = "#CCFFCC"; }else{ $color = "#FFFFCC"; } echo '<td style="padding: 6px" align="center" bgcolor="'.$color.'"><a href="calendar.php?pge&monthnow='.$monthnum.'&yearnow='.$year.'&add='.$_GET['add'].'&appt='.$link_date.'">'.$day.'</a></td>'; if($wday==6) { echo '</tr>'; } $wday++; $wday = $wday % 7; $day++; } echo ' </table> </form> Thanks Link to comment https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/ Share on other sites More sharing options...
bob_the _builder Posted March 10, 2008 Author Share Posted March 10, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/#findComment-488759 Share on other sites More sharing options...
revraz Posted March 10, 2008 Share Posted March 10, 2008 You are comparing it to itself if($day == $day){ Link to comment https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/#findComment-488812 Share on other sites More sharing options...
bob_the _builder Posted March 11, 2008 Author Share Posted March 11, 2008 Hi, Yer, I have tried so many ways to make it happen, but cant get the logic right. Thats was just what was there when I copied and pasted the code. Any ideas on the general concept to make it happen? Thanks Link to comment https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/#findComment-489054 Share on other sites More sharing options...
haku Posted March 11, 2008 Share Posted March 11, 2008 General concept: Where are you inserting events into the day? At that point, check to see if there actually are any events to be entered into the day. If there are, then add a class name to the tag, then use css to set the style of that class. Link to comment https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/#findComment-489058 Share on other sites More sharing options...
bob_the _builder Posted March 11, 2008 Author Share Posted March 11, 2008 Hi, I have this code above the form: if(isset($_GET['prev'])){ if($_GET['prev'] == 'prev') { $monthnum = $_GET['monthnow']--; }else{ $monthnum = $_GET['monthnow']++; } $date = getdate(mktime(0,0,0,$_GET['monthnow'],1,$_GET['yearnow'])); }else{ $date = getdate(); } if((isset($_GET['pge'])) || (isset($_GET['all']))){ $monthnum = $_GET['monthnow']; $date = getdate(mktime(0,0,0,$_GET['monthnow'],1,$_GET['yearnow'])); } $monthnum = $date['mon']; $monthname = $date['month']; $year = $date['year']; $datetoday = getdate(mktime(0,0,0,$monthnum,1,$year)); $firstweekay = $datetoday['wday']; $cont = true; $today = 27; if(!isset($_GET['appt'])){ $appt = date("Y-m-d"); }else{ $appt = $_GET['appt']; } while(($today <= 32) && ($cont)) { $datetoday = getdate(mktime(0,0,0,$monthnum,$today,$year)); if($datetoday['mon'] != $monthnum) { $lastday = $today - 1; $cont = false; } $today++; } $day only hold the day as its value. In the database when an appointment is added it gets stored under "startdate" field as date/time. Basically trying to find $today value and days that match $startdate. Just have no idea how .. have tried a few ways but no success, just changes all the boxes with either or colour. Thanks Link to comment https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/#findComment-489060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.