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 Quote Link to comment Share on other sites More sharing options...
bob_the _builder Posted March 10, 2008 Author Share Posted March 10, 2008 Anyone? Quote Link to comment 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){ Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 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.