localhost1 Posted October 2, 2007 Share Posted October 2, 2007 hi all this problem of mine really needs an urgent help. i have code in which i need to change the color of the date which is holiday of an organization. and the holiday date is determined from the value added in the database which is done from admin panel. Now what i want to do is read all the dates from the database which are inserted from admin panel and check the date with each dates of the calender. if the date from the database is same with the dates of the calender then give another CSS class for the date. my previous code in which simple calender is displayed where no holidays is considered is like this <?php ob_start(); require_once("config.php"); require_once("user_info.class.php"); if(isset($_REQUEST['mon'])) $month=$_REQUEST['mon']; else $month=date("n"); if(isset($_REQUEST['yr'])) $year=$_REQUEST['yr']; else $year=date("Y"); $date=date("d"); function DisplayCalender($id,$month,$year) { $bankHolsThisYear = calculateBankHolidays($year); $date=date("d"); $month_curr=date("n"); $year_curr=date("Y"); $cnt=count($bankHolsThisYear); $date_class="cal_font"; $symbol1="car_sym"; $symbol2="sym2"; $gender=""; $sdate=$year."/".$month."/01"; $edate=$year."/".$month."/31"; echo"<table border=0 cellspacing=0 cellpadding=0 align=center width='275px'>"; echo"<tr><td class=cal_head align=center>Dim</td><td class=cal_head align=center>Lun</td><td class=cal_head align=center>Mar</td>"; echo"<td class=cal_head align=center>Mer</td><td class=cal_head align=center>Jeu</td><td class=cal_head align=center>Ven</td><td class=cal_head align=center>Sam</td></tr>"; $day= date("D",mktime(0, 0, 0,$month, 1,date("y"))); $no=1; $dayno=0; echo "<tr>"; switch($day) { case "Sun": break; case "Mon": $dayno=1; break; case "Tue": $dayno=2; break; case "Wed": $dayno=3; break; case "Thu": $dayno=4; break; case "Fri": $dayno=5; break; case "Sat": $dayno=6; break; } for($i=0;$i<$dayno;$i++) { // this is for first row image... echo '<td class=cal_mes_bg align="center"> </td>'; } if($dayno==0) $class_bg="cal_dimanches_bg"; else $class_bg="cal_mes_bg"; if($date==1 && $year_curr==$year && $month_curr==$month) { $class_bg="cal_current_bg"; $date_class="cal_font_current"; $symbol1="car_curr"; $symbol2="curr_sym"; } echo"<td align=\"center\"> <table width=\"92%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"center\" valign=\"middle\" class=\"cal_font\"><a href=\"#\" onClick=\"return popup('reservation.php?myseldate=1".'-'.$month.'-'.$year."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=1".'-'.$month.' -'.$year."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$date_class.">1</a></td> <td style=\"width:3px\"></td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; //} // end of else $no=$dayno+1; if($month==4||$month==6||$month==9||$month==11) $max=30; else if($month==1||$month==3||$month==5||$month==7||$month==8||$month==10||$month== 12) $max=31; else if($month==2) { $x=$year%4; if($x==0) $max=29; else $max=28; } for($i=2;$i<=$max;$i++) { if($no==7||$no==14||$no==21||$no==28||$no==35) { $class_bg="vaskar"; echo"<tr>"; } else { $class_bg="cal_mes_bg"; } //$edate=$year."/".$month."/".$i; $date_class="cal_font"; /*$symbol1="car_sym"; $symbol2="sym2";*/ if($i==$date && $year_curr==$year && $month_curr==$month) { // save the curr date in session $_SESSION['mycurrdate']=$year_curr.'-'.$month_curr.'-'.$i; $_SESSION['myselecteddate']=$month_curr.'-'.$year_curr; $_SESSION['currmonth'] = $month_curr; $_SESSION['curryear'] = $year_curr; $class_bg="cal_font_current"; $date_class="cal_font_current"; //$symbol1="car_curr"; //$symbol2="curr_sym"; } // changed here /* if(checkEvent($gender,$edate)=="true") { echo"<td class=gen><a href='eventsearchlist.php?sflag=2&gender=".$gender."&type=2&edate=".$edate."'> ".$i."</a></td>"; } else {*/ echo "<td class=".$date_class."> <table width=\"25\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"right\" valign=\"top\" class=".$date_class.">"; if (@$_SESSION['logged_in']==true) { echo "<a href=\"#\" onClick=\"return popup('reservation.php?myseldate=".$year.'-'.$month.'-'.$i."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$mo nth.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } else { echo "<a href=\"#\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$mo nth.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } echo "</td> <td style=\"width:3px\">"; $_SESSION['mydate']= $i; echo " </td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; // } // end of else $no=$no+1; } $cross=0; $day_last= date("D",mktime(0, 0, 0,$month, $max,date("y"))); switch($day_last) { case "Sun": $cross=6; break; case "Mon": $cross=5; break; case "Tue": $cross=4; break; case "Wed": $cross=3; break; case "Thu": $cross=2; break; case "Fri": $cross=1; break; case "Sat": break; } for($i=0;$i<$cross;$i++) { echo '<td class=cal_mes_bg align="center"> </td>'; } echo"</table>"; } function CheckEvent($gender,$fromdate) { // $rs=mysql_query("select * from event where gender='".$gender ."' and edate='".$fromdate."'"); //$rsNum=mysql_num_rows($rs); $rsNum=""; if($rsNum!=0) { return "true"; } else { return "false"; } } function calculateBankHolidays($yr) { $bankHols = Array(); $yr = 2000; // New year's: switch (date("w", strtotime("$yr-01-01 12:00:00")) ) { //switch ( getdate("w", strtotime("$yr-01-01 12:00:00")) ) { //this is line 413 case 6: $bankHols[] = "$yr-01-03"; break; case 0: $bankHols[] = "$yr-01-02"; break; default: $bankHols[] = "$yr-01-01"; } // Good friday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) - 2)." days", strtotime("$yr-03-21 12:00:00") )); // Easter Monday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) + 1)." days", strtotime("$yr-03-21 12:00:00") )); // May Day: if ($yr == 1995) { $bankHols[] = "1995-05-08"; // VE day 50th anniversary year exception } else { switch (date("w", strtotime("$yr-05-01 12:00:00"))) { case 0: $bankHols[] = "$yr-05-02"; break; case 1: $bankHols[] = "$yr-05-01"; break; case 2: $bankHols[] = "$yr-05-07"; break; case 3: $bankHols[] = "$yr-05-06"; break; case 4: $bankHols[] = "$yr-05-05"; break; case 5: $bankHols[] = "$yr-05-04"; break; case 6: $bankHols[] = "$yr-05-03"; break; } } // Whitsun: if ($yr == 2002) { // exception year $bankHols[] = "2002-06-03"; $bankHols[] = "2002-06-04"; } else { switch (date("w", strtotime("$yr-05-31 12:00:00"))) { case 0: $bankHols[] = "$yr-05-25"; break; case 1: $bankHols[] = "$yr-05-31"; break; case 2: $bankHols[] = "$yr-05-30"; break; case 3: $bankHols[] = "$yr-05-29"; break; case 4: $bankHols[] = "$yr-05-28"; break; case 5: $bankHols[] = "$yr-05-27"; break; case 6: $bankHols[] = "$yr-05-26"; break; } } // Summer Bank Holiday: switch (date("w", strtotime("$yr-08-31 12:00:00"))) { case 0: $bankHols[] = "$yr-08-25"; break; case 1: $bankHols[] = "$yr-08-31"; break; case 2: $bankHols[] = "$yr-08-30"; break; case 3: $bankHols[] = "$yr-08-29"; break; case 4: $bankHols[] = "$yr-08-28"; break; case 5: $bankHols[] = "$yr-08-27"; break; case 6: $bankHols[] = "$yr-08-26"; break; } // Christmas: switch ( date("w", strtotime("$yr-12-25 12:00:00")) ) { case 5: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-28"; break; case 6: $bankHols[] = "$yr-12-27"; $bankHols[] = "$yr-12-28"; break; case 0: $bankHols[] = "$yr-12-26"; $bankHols[] = "$yr-12-27"; break; default: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-26"; } // Millenium eve if ($yr == 1999) { $bankHols[] = "1999-12-31"; } return $bankHols; } ?> <script> function cal_prev(mon,yr,id) { if (mon==1) { mon=12; yr--; } else mon--; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } function cal_next(mon,yr,id) { if (mon==12) { mon=1; yr++; } else mon++; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } </script> <form name="frm_cal_sm" method="post"> <table width="247" border="0" cellpadding="0" cellspacing="0" bgcolor="#AA0F61"> <!--DWLayoutTable--> <tr> <? $month_curr=date("n"); if($month!= $month_curr) { ?> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_prev(<?=$month?>,<?=$year?>)" class="cal_normal_sm"><</a></td> <? }?> <td width="212" height="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><? $ref= $year.'-'.$month.'-'.$date; echo $ref; ?></td> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_next(<?=$month?>,<?=$year?>)" class="cal_normal_sm">></a></td> </tr> <tr> <td height="226" colspan="3" valign="top" bgcolor="#EB208C"><? DisplayCalender($id,$month,$year); ob_end_flush(); ?></td> </tr> </table> </form> </body> </html> and later i tried this with condition to check if the dates from database and the calender are same is like this. the section of the code distinct from above is written between /////////////////////////// sign. which is as folows <?php ob_start(); require_once("config.php"); require_once("user_info.class.php"); if(isset($_REQUEST['mon'])) $month=$_REQUEST['mon']; else $month=date("n"); if(isset($_REQUEST['yr'])) $year=$_REQUEST['yr']; else $year=date("Y"); $date=date("d"); function DisplayCalender($id,$month,$year) { $bankHolsThisYear = calculateBankHolidays($year); $date=date("d"); $month_curr=date("n"); $year_curr=date("Y"); $cnt=count($bankHolsThisYear); $date_class="cal_font"; $symbol1="car_sym"; $symbol2="sym2"; $gender=""; $sdate=$year."/".$month."/01"; $edate=$year."/".$month."/31"; echo"<table border=0 cellspacing=0 cellpadding=0 align=center width='275px'>"; echo"<tr><td class=cal_head align=center>Dim</td><td class=cal_head align=center>Lun</td><td class=cal_head align=center>Mar</td>"; echo"<td class=cal_head align=center>Mer</td><td class=cal_head align=center>Jeu</td><td class=cal_head align=center>Ven</td><td class=cal_head align=center>Sam</td></tr>"; $day= date("D",mktime(0, 0, 0,$month, 1,date("y"))); $no=1; $dayno=0; echo "<tr>"; switch($day) { case "Sun": break; case "Mon": $dayno=1; break; case "Tue": $dayno=2; break; case "Wed": $dayno=3; break; case "Thu": $dayno=4; break; case "Fri": $dayno=5; break; case "Sat": $dayno=6; break; } for($i=0;$i<$dayno;$i++) { // this is for first row image... echo '<td class=cal_mes_bg align="center"> </td>'; } if($dayno==0) $class_bg="cal_dimanches_bg"; else $class_bg="cal_mes_bg"; if($date==1 && $year_curr==$year && $month_curr==$month) { $class_bg="cal_current_bg"; $date_class="cal_font_current"; $symbol1="car_curr"; $symbol2="curr_sym"; } echo"<td align=\"center\"> <table width=\"92%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"center\" valign=\"middle\" class=\"cal_font\"><a href=\"#\" onClick=\"return popup('reservation.php?myseldate=1".'-'.$month.'-'.$year."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=1".'-'.$month.' -'.$year."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$date_class.">1</a></td> <td style=\"width:3px\"></td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; //} // end of else $no=$dayno+1; if($month==4||$month==6||$month==9||$month==11) $max=30; else if($month==1||$month==3||$month==5||$month==7||$month==8||$month==10||$month== 12) $max=31; else if($month==2) { $x=$year%4; if($x==0) $max=29; else $max=28; } for($i=2;$i<=$max;$i++) { if($no==7||$no==14||$no==21||$no==28||$no==35) { $class_bg="vaskar"; echo"<tr>"; } else { $class_bg="cal_mes_bg"; } //$edate=$year."/".$month."/".$i; $date_class="cal_font"; /*$symbol1="car_sym"; $symbol2="sym2";*/ if($i==$date && $year_curr==$year && $month_curr==$month) { // save the curr date in session $_SESSION['mycurrdate']=$year_curr.'-'.$month_curr.'-'.$i; $_SESSION['myselecteddate']=$month_curr.'-'.$year_curr; $_SESSION['currmonth'] = $month_curr; $_SESSION['curryear'] = $year_curr; $class_bg="cal_font_current"; $date_class="cal_font_current"; //$symbol1="car_curr"; //$symbol2="curr_sym"; } ////////////////////////////////////////////////////////////// $query="select holiday_date from voyance_holidays where holiday_reservationtype='Telephone Reservation'"; //echo $query; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { //$d=$year."-".$month."-".$i; $string=$row['holiday_date']; $pieces=explode("-",$string); if($i==$pieces[2]) { $class_bg="cal_font_holiday"; } else { $class_bg="cal_font_current"; } } /////////////////////////////////////////////////////////////// // changed here /* if(checkEvent($gender,$edate)=="true") { echo"<td class=gen><a href='eventsearchlist.php?sflag=2&gender=".$gender."&type=2&edate=".$edate."'> ".$i."</a></td>"; } else {*/ echo "<td class=".$date_class."> <table width=\"25\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"right\" valign=\"top\" class=".$date_class.">"; if (@$_SESSION['logged_in']==true) { echo "<a href=\"#\" onClick=\"return popup('reservation.php?myseldate=".$year.'-'.$month.'-'.$i."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$mo nth.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } else { echo "<a href=\"#\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$mo nth.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } echo "</td> <td style=\"width:3px\">"; $_SESSION['mydate']= $i; echo " </td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; // } // end of else $no=$no+1; } $cross=0; $day_last= date("D",mktime(0, 0, 0,$month, $max,date("y"))); switch($day_last) { case "Sun": $cross=6; break; case "Mon": $cross=5; break; case "Tue": $cross=4; break; case "Wed": $cross=3; break; case "Thu": $cross=2; break; case "Fri": $cross=1; break; case "Sat": break; } for($i=0;$i<$cross;$i++) { echo '<td class=cal_mes_bg align="center"> </td>'; } echo"</table>"; } function CheckEvent($gender,$fromdate) { // $rs=mysql_query("select * from event where gender='".$gender ."' and edate='".$fromdate."'"); //$rsNum=mysql_num_rows($rs); $rsNum=""; if($rsNum!=0) { return "true"; } else { return "false"; } } function calculateBankHolidays($yr) { $bankHols = Array(); $yr = 2000; // New year's: switch (date("w", strtotime("$yr-01-01 12:00:00")) ) { //switch ( getdate("w", strtotime("$yr-01-01 12:00:00")) ) { //this is line 413 case 6: $bankHols[] = "$yr-01-03"; break; case 0: $bankHols[] = "$yr-01-02"; break; default: $bankHols[] = "$yr-01-01"; } // Good friday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) - 2)." days", strtotime("$yr-03-21 12:00:00") )); // Easter Monday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) + 1)." days", strtotime("$yr-03-21 12:00:00") )); // May Day: if ($yr == 1995) { $bankHols[] = "1995-05-08"; // VE day 50th anniversary year exception } else { switch (date("w", strtotime("$yr-05-01 12:00:00"))) { case 0: $bankHols[] = "$yr-05-02"; break; case 1: $bankHols[] = "$yr-05-01"; break; case 2: $bankHols[] = "$yr-05-07"; break; case 3: $bankHols[] = "$yr-05-06"; break; case 4: $bankHols[] = "$yr-05-05"; break; case 5: $bankHols[] = "$yr-05-04"; break; case 6: $bankHols[] = "$yr-05-03"; break; } } // Whitsun: if ($yr == 2002) { // exception year $bankHols[] = "2002-06-03"; $bankHols[] = "2002-06-04"; } else { switch (date("w", strtotime("$yr-05-31 12:00:00"))) { case 0: $bankHols[] = "$yr-05-25"; break; case 1: $bankHols[] = "$yr-05-31"; break; case 2: $bankHols[] = "$yr-05-30"; break; case 3: $bankHols[] = "$yr-05-29"; break; case 4: $bankHols[] = "$yr-05-28"; break; case 5: $bankHols[] = "$yr-05-27"; break; case 6: $bankHols[] = "$yr-05-26"; break; } } // Summer Bank Holiday: switch (date("w", strtotime("$yr-08-31 12:00:00"))) { case 0: $bankHols[] = "$yr-08-25"; break; case 1: $bankHols[] = "$yr-08-31"; break; case 2: $bankHols[] = "$yr-08-30"; break; case 3: $bankHols[] = "$yr-08-29"; break; case 4: $bankHols[] = "$yr-08-28"; break; case 5: $bankHols[] = "$yr-08-27"; break; case 6: $bankHols[] = "$yr-08-26"; break; } // Christmas: switch ( date("w", strtotime("$yr-12-25 12:00:00")) ) { case 5: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-28"; break; case 6: $bankHols[] = "$yr-12-27"; $bankHols[] = "$yr-12-28"; break; case 0: $bankHols[] = "$yr-12-26"; $bankHols[] = "$yr-12-27"; break; default: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-26"; } // Millenium eve if ($yr == 1999) { $bankHols[] = "1999-12-31"; } return $bankHols; } ?> <script> function cal_prev(mon,yr,id) { if (mon==1) { mon=12; yr--; } else mon--; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } function cal_next(mon,yr,id) { if (mon==12) { mon=1; yr++; } else mon++; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } </script> <form name="frm_cal_sm" method="post"> <table width="247" border="0" cellpadding="0" cellspacing="0" bgcolor="#AA0F61"> <!--DWLayoutTable--> <tr> <? $month_curr=date("n"); if($month!= $month_curr) { ?> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_prev(<?=$month?>,<?=$year?>)" class="cal_normal_sm"><</a></td> <? }?> <td width="212" height="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><? $ref= $year.'-'.$month.'-'.$date; echo $ref; ?></td> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_next(<?=$month?>,<?=$year?>)" class="cal_normal_sm">></a></td> </tr> <tr> <td height="226" colspan="3" valign="top" bgcolor="#EB208C"><? DisplayCalender($id,$month,$year); ob_end_flush(); ?></td> </tr> </table> </form> </body> </html> it is really an urgent. please helo in this regard thank you Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/ Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 the problem seams to be here <?php $query="select holiday_date from voyance_holidays where holiday_reservationtype='Telephone Reservation'"; //echo $query; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { //$d=$year."-".$month."-".$i; $string=$row['holiday_date']; $pieces=explode("-",$string); if($i==$pieces[2]) { $class_bg="cal_font_holiday"; } else { $class_bg="cal_font_current"; } }?> i'll explain, as you loop throught the records, $class_bg will only be set to the LAST records, as its a loop i assume that the request find a set.. so what you need to do, is change it to something like to something like this <?php $query="select holiday_date from voyance_holidays where holiday_reservationtype='Telephone Reservation'"; //echo $query; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { //$d=$year."-".$month."-".$i; $string=$row['holiday_date']; $pieces=explode("-",$string); if($i==$pieces[2]) { $class_bg[$i]="cal_font_holiday"; } else { $class_bg[$i]="cal_font_current"; } }?> then change the TWO uses below from class=".$class_bg." to class=".$class_bg[$i]." [updated - to make sence!] EDIT: Please Note i only skimmed the code and it does need cleaning up, also "urgent" work should be posted in the freelance section with an offer , free help you have to wait for Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359883 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Author Share Posted October 2, 2007 hi all this problem of mine really needs an urgent help. i have code in which i need to change the color of the date which is holiday of an organization. and the holiday date is determined from the value added in the database which is done from admin panel. Now what i want to do is read all the dates from the database which are inserted from admin panel and check the date with each dates of the calender. if the date from the database is same with the dates of the calender then give another CSS class for the date. my previous code in which simple calender is displayed where no holidays is considered is like this <?php ob_start(); require_once("config.php"); require_once("user_info.class.php"); if(isset($_REQUEST['mon'])) $month=$_REQUEST['mon']; else $month=date("n"); if(isset($_REQUEST['yr'])) $year=$_REQUEST['yr']; else $year=date("Y"); $date=date("d"); function DisplayCalender($id,$month,$year) { $bankHolsThisYear = calculateBankHolidays($year); $date=date("d"); $month_curr=date("n"); $year_curr=date("Y"); $cnt=count($bankHolsThisYear); $date_class="cal_font"; $symbol1="car_sym"; $symbol2="sym2"; $gender=""; $sdate=$year."/".$month."/01"; $edate=$year."/".$month."/31"; echo"<table border=0 cellspacing=0 cellpadding=0 align=center width='275px'>"; echo"<tr><td class=cal_head align=center>Dim</td><td class=cal_head align=center>Lun</td><td class=cal_head align=center>Mar</td>"; echo"<td class=cal_head align=center>Mer</td><td class=cal_head align=center>Jeu</td><td class=cal_head align=center>Ven</td><td class=cal_head align=center>Sam</td></tr>"; $day= date("D",mktime(0, 0, 0,$month, 1,date("y"))); $no=1; $dayno=0; echo "<tr>"; switch($day) { case "Sun": break; case "Mon": $dayno=1; break; case "Tue": $dayno=2; break; case "Wed": $dayno=3; break; case "Thu": $dayno=4; break; case "Fri": $dayno=5; break; case "Sat": $dayno=6; break; } for($i=0;$i<$dayno;$i++) { // this is for first row image... echo '<td class=cal_mes_bg align="center"> </td>'; } if($dayno==0) $class_bg="cal_dimanches_bg"; else $class_bg="cal_mes_bg"; if($date==1 && $year_curr==$year && $month_curr==$month) { $class_bg="cal_current_bg"; $date_class="cal_font_current"; $symbol1="car_curr"; $symbol2="curr_sym"; } echo"<td align=\"center\"> <table width=\"92%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"center\" valign=\"middle\" class=\"cal_font\"><a href=\"#\" onClick=\"return popup('reservation.php?myseldate=1".'-'.$month.'-'.$year."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=1".'-'.$month.'-'.$year."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$date_class.">1</a></td> <td style=\"width:3px\"></td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; //} // end of else $no=$dayno+1; if($month==4||$month==6||$month==9||$month==11) $max=30; else if($month==1||$month==3||$month==5||$month==7||$month==8||$month==10||$month==12) $max=31; else if($month==2) { $x=$year%4; if($x==0) $max=29; else $max=28; } for($i=2;$i<=$max;$i++) { if($no==7||$no==14||$no==21||$no==28||$no==35) { $class_bg="vaskar"; echo"<tr>"; } else { $class_bg="cal_mes_bg"; } //$edate=$year."/".$month."/".$i; $date_class="cal_font"; /*$symbol1="car_sym"; $symbol2="sym2";*/ if($i==$date && $year_curr==$year && $month_curr==$month) { // save the curr date in session $_SESSION['mycurrdate']=$year_curr.'-'.$month_curr.'-'.$i; $_SESSION['myselecteddate']=$month_curr.'-'.$year_curr; $_SESSION['currmonth'] = $month_curr; $_SESSION['curryear'] = $year_curr; $class_bg="cal_font_current"; $date_class="cal_font_current"; //$symbol1="car_curr"; //$symbol2="curr_sym"; } // changed here /* if(checkEvent($gender,$edate)=="true") { echo"<td class=gen><a href='eventsearchlist.php?sflag=2&gender=".$gender."&type=2&edate=".$edate."'>".$i."</a></td>"; } else {*/ echo "<td class=".$date_class."> <table width=\"25\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"right\" valign=\"top\" class=".$date_class.">"; if (@$_SESSION['logged_in']==true) { echo "<a href=\"#\" onClick=\"return popup('reservation.php?myseldate=".$year.'-'.$month.'-'.$i."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$month.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } else { echo "<a href=\"#\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$month.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } echo "</td> <td style=\"width:3px\">"; $_SESSION['mydate']= $i; echo " </td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; // } // end of else $no=$no+1; } $cross=0; $day_last= date("D",mktime(0, 0, 0,$month, $max,date("y"))); switch($day_last) { case "Sun": $cross=6; break; case "Mon": $cross=5; break; case "Tue": $cross=4; break; case "Wed": $cross=3; break; case "Thu": $cross=2; break; case "Fri": $cross=1; break; case "Sat": break; } for($i=0;$i<$cross;$i++) { echo '<td class=cal_mes_bg align="center"> </td>'; } echo"</table>"; } function CheckEvent($gender,$fromdate) { // $rs=mysql_query("select * from event where gender='".$gender ."' and edate='".$fromdate."'"); //$rsNum=mysql_num_rows($rs); $rsNum=""; if($rsNum!=0) { return "true"; } else { return "false"; } } function calculateBankHolidays($yr) { $bankHols = Array(); $yr = 2000; // New year's: switch (date("w", strtotime("$yr-01-01 12:00:00")) ) { //switch ( getdate("w", strtotime("$yr-01-01 12:00:00")) ) { //this is line 413 case 6: $bankHols[] = "$yr-01-03"; break; case 0: $bankHols[] = "$yr-01-02"; break; default: $bankHols[] = "$yr-01-01"; } // Good friday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) - 2)." days", strtotime("$yr-03-21 12:00:00") )); // Easter Monday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) + 1)." days", strtotime("$yr-03-21 12:00:00") )); // May Day: if ($yr == 1995) { $bankHols[] = "1995-05-08"; // VE day 50th anniversary year exception } else { switch (date("w", strtotime("$yr-05-01 12:00:00"))) { case 0: $bankHols[] = "$yr-05-02"; break; case 1: $bankHols[] = "$yr-05-01"; break; case 2: $bankHols[] = "$yr-05-07"; break; case 3: $bankHols[] = "$yr-05-06"; break; case 4: $bankHols[] = "$yr-05-05"; break; case 5: $bankHols[] = "$yr-05-04"; break; case 6: $bankHols[] = "$yr-05-03"; break; } } // Whitsun: if ($yr == 2002) { // exception year $bankHols[] = "2002-06-03"; $bankHols[] = "2002-06-04"; } else { switch (date("w", strtotime("$yr-05-31 12:00:00"))) { case 0: $bankHols[] = "$yr-05-25"; break; case 1: $bankHols[] = "$yr-05-31"; break; case 2: $bankHols[] = "$yr-05-30"; break; case 3: $bankHols[] = "$yr-05-29"; break; case 4: $bankHols[] = "$yr-05-28"; break; case 5: $bankHols[] = "$yr-05-27"; break; case 6: $bankHols[] = "$yr-05-26"; break; } } // Summer Bank Holiday: switch (date("w", strtotime("$yr-08-31 12:00:00"))) { case 0: $bankHols[] = "$yr-08-25"; break; case 1: $bankHols[] = "$yr-08-31"; break; case 2: $bankHols[] = "$yr-08-30"; break; case 3: $bankHols[] = "$yr-08-29"; break; case 4: $bankHols[] = "$yr-08-28"; break; case 5: $bankHols[] = "$yr-08-27"; break; case 6: $bankHols[] = "$yr-08-26"; break; } // Christmas: switch ( date("w", strtotime("$yr-12-25 12:00:00")) ) { case 5: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-28"; break; case 6: $bankHols[] = "$yr-12-27"; $bankHols[] = "$yr-12-28"; break; case 0: $bankHols[] = "$yr-12-26"; $bankHols[] = "$yr-12-27"; break; default: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-26"; } // Millenium eve if ($yr == 1999) { $bankHols[] = "1999-12-31"; } return $bankHols; } ?> <script> function cal_prev(mon,yr,id) { if (mon==1) { mon=12; yr--; } else mon--; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } function cal_next(mon,yr,id) { if (mon==12) { mon=1; yr++; } else mon++; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } </script> <form name="frm_cal_sm" method="post"> <table width="247" border="0" cellpadding="0" cellspacing="0" bgcolor="#AA0F61"> <!--DWLayoutTable--> <tr> <? $month_curr=date("n"); if($month!= $month_curr) { ?> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_prev(<?=$month?>,<?=$year?>)" class="cal_normal_sm"><</a></td> <? }?> <td width="212" height="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><? $ref= $year.'-'.$month.'-'.$date; echo $ref; ?></td> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_next(<?=$month?>,<?=$year?>)" class="cal_normal_sm">></a></td> </tr> <tr> <td height="226" colspan="3" valign="top" bgcolor="#EB208C"><? DisplayCalender($id,$month,$year); ob_end_flush(); ?></td> </tr> </table> </form> </body> </html> and later i tried this with condition to check if the dates from database and the calender are same is like this. the section of the code distinct from above is written between /////////////////////////// sign. which is as folows <?php ob_start(); require_once("config.php"); require_once("user_info.class.php"); if(isset($_REQUEST['mon'])) $month=$_REQUEST['mon']; else $month=date("n"); if(isset($_REQUEST['yr'])) $year=$_REQUEST['yr']; else $year=date("Y"); $date=date("d"); function DisplayCalender($id,$month,$year) { $bankHolsThisYear = calculateBankHolidays($year); $date=date("d"); $month_curr=date("n"); $year_curr=date("Y"); $cnt=count($bankHolsThisYear); $date_class="cal_font"; $symbol1="car_sym"; $symbol2="sym2"; $gender=""; $sdate=$year."/".$month."/01"; $edate=$year."/".$month."/31"; echo"<table border=0 cellspacing=0 cellpadding=0 align=center width='275px'>"; echo"<tr><td class=cal_head align=center>Dim</td><td class=cal_head align=center>Lun</td><td class=cal_head align=center>Mar</td>"; echo"<td class=cal_head align=center>Mer</td><td class=cal_head align=center>Jeu</td><td class=cal_head align=center>Ven</td><td class=cal_head align=center>Sam</td></tr>"; $day= date("D",mktime(0, 0, 0,$month, 1,date("y"))); $no=1; $dayno=0; echo "<tr>"; switch($day) { case "Sun": break; case "Mon": $dayno=1; break; case "Tue": $dayno=2; break; case "Wed": $dayno=3; break; case "Thu": $dayno=4; break; case "Fri": $dayno=5; break; case "Sat": $dayno=6; break; } for($i=0;$i<$dayno;$i++) { // this is for first row image... echo '<td class=cal_mes_bg align="center"> </td>'; } if($dayno==0) $class_bg="cal_dimanches_bg"; else $class_bg="cal_mes_bg"; if($date==1 && $year_curr==$year && $month_curr==$month) { $class_bg="cal_current_bg"; $date_class="cal_font_current"; $symbol1="car_curr"; $symbol2="curr_sym"; } echo"<td align=\"center\"> <table width=\"92%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"center\" valign=\"middle\" class=\"cal_font\"><a href=\"#\" onClick=\"return popup('reservation.php?myseldate=1".'-'.$month.'-'.$year."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=1".'-'.$month.'-'.$year."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$date_class.">1</a></td> <td style=\"width:3px\"></td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; //} // end of else $no=$dayno+1; if($month==4||$month==6||$month==9||$month==11) $max=30; else if($month==1||$month==3||$month==5||$month==7||$month==8||$month==10||$month==12) $max=31; else if($month==2) { $x=$year%4; if($x==0) $max=29; else $max=28; } for($i=2;$i<=$max;$i++) { if($no==7||$no==14||$no==21||$no==28||$no==35) { $class_bg="vaskar"; echo"<tr>"; } else { $class_bg="cal_mes_bg"; } //$edate=$year."/".$month."/".$i; $date_class="cal_font"; /*$symbol1="car_sym"; $symbol2="sym2";*/ if($i==$date && $year_curr==$year && $month_curr==$month) { // save the curr date in session $_SESSION['mycurrdate']=$year_curr.'-'.$month_curr.'-'.$i; $_SESSION['myselecteddate']=$month_curr.'-'.$year_curr; $_SESSION['currmonth'] = $month_curr; $_SESSION['curryear'] = $year_curr; $class_bg="cal_font_current"; $date_class="cal_font_current"; //$symbol1="car_curr"; //$symbol2="curr_sym"; } ////////////////////////////////////////////////////////////// $query="select holiday_date from voyance_holidays where holiday_reservationtype='Telephone Reservation'"; //echo $query; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { //$d=$year."-".$month."-".$i; $string=$row['holiday_date']; $pieces=explode("-",$string); if($i==$pieces[2]) { $class_bg="cal_font_holiday"; } else { $class_bg="cal_font_current"; } } /////////////////////////////////////////////////////////////// // changed here /* if(checkEvent($gender,$edate)=="true") { echo"<td class=gen><a href='eventsearchlist.php?sflag=2&gender=".$gender."&type=2&edate=".$edate."'>".$i."</a></td>"; } else {*/ echo "<td class=".$date_class."> <table width=\"25\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\"> <tr> <td> </td> <td align=\"right\" valign=\"top\" class=".$date_class.">"; if (@$_SESSION['logged_in']==true) { echo "<a href=\"#\" onClick=\"return popup('reservation.php?myseldate=".$year.'-'.$month.'-'.$i."', 'v1', '300', '266')\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$month.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } else { echo "<a href=\"#\" onMouseOver=\"ajax_showTooltip('view_reservation.php?myseldate=".$year.'-'.$month.'-'.$i."',this);return false\" onmouseout=\"ajax_hideTooltip();\" class=".$class_bg.">".$i."</a>"; } echo "</td> <td style=\"width:3px\">"; $_SESSION['mydate']= $i; echo " </td> </tr> <tr> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" style=\"height:8px\"></td> </tr> </table></td> </tr> </table> </td>"; // } // end of else $no=$no+1; } $cross=0; $day_last= date("D",mktime(0, 0, 0,$month, $max,date("y"))); switch($day_last) { case "Sun": $cross=6; break; case "Mon": $cross=5; break; case "Tue": $cross=4; break; case "Wed": $cross=3; break; case "Thu": $cross=2; break; case "Fri": $cross=1; break; case "Sat": break; } for($i=0;$i<$cross;$i++) { echo '<td class=cal_mes_bg align="center"> </td>'; } echo"</table>"; } function CheckEvent($gender,$fromdate) { // $rs=mysql_query("select * from event where gender='".$gender ."' and edate='".$fromdate."'"); //$rsNum=mysql_num_rows($rs); $rsNum=""; if($rsNum!=0) { return "true"; } else { return "false"; } } function calculateBankHolidays($yr) { $bankHols = Array(); $yr = 2000; // New year's: switch (date("w", strtotime("$yr-01-01 12:00:00")) ) { //switch ( getdate("w", strtotime("$yr-01-01 12:00:00")) ) { //this is line 413 case 6: $bankHols[] = "$yr-01-03"; break; case 0: $bankHols[] = "$yr-01-02"; break; default: $bankHols[] = "$yr-01-01"; } // Good friday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) - 2)." days", strtotime("$yr-03-21 12:00:00") )); // Easter Monday: $bankHols[] = date("Y-m-d", strtotime( "+".(easter_days($yr) + 1)." days", strtotime("$yr-03-21 12:00:00") )); // May Day: if ($yr == 1995) { $bankHols[] = "1995-05-08"; // VE day 50th anniversary year exception } else { switch (date("w", strtotime("$yr-05-01 12:00:00"))) { case 0: $bankHols[] = "$yr-05-02"; break; case 1: $bankHols[] = "$yr-05-01"; break; case 2: $bankHols[] = "$yr-05-07"; break; case 3: $bankHols[] = "$yr-05-06"; break; case 4: $bankHols[] = "$yr-05-05"; break; case 5: $bankHols[] = "$yr-05-04"; break; case 6: $bankHols[] = "$yr-05-03"; break; } } // Whitsun: if ($yr == 2002) { // exception year $bankHols[] = "2002-06-03"; $bankHols[] = "2002-06-04"; } else { switch (date("w", strtotime("$yr-05-31 12:00:00"))) { case 0: $bankHols[] = "$yr-05-25"; break; case 1: $bankHols[] = "$yr-05-31"; break; case 2: $bankHols[] = "$yr-05-30"; break; case 3: $bankHols[] = "$yr-05-29"; break; case 4: $bankHols[] = "$yr-05-28"; break; case 5: $bankHols[] = "$yr-05-27"; break; case 6: $bankHols[] = "$yr-05-26"; break; } } // Summer Bank Holiday: switch (date("w", strtotime("$yr-08-31 12:00:00"))) { case 0: $bankHols[] = "$yr-08-25"; break; case 1: $bankHols[] = "$yr-08-31"; break; case 2: $bankHols[] = "$yr-08-30"; break; case 3: $bankHols[] = "$yr-08-29"; break; case 4: $bankHols[] = "$yr-08-28"; break; case 5: $bankHols[] = "$yr-08-27"; break; case 6: $bankHols[] = "$yr-08-26"; break; } // Christmas: switch ( date("w", strtotime("$yr-12-25 12:00:00")) ) { case 5: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-28"; break; case 6: $bankHols[] = "$yr-12-27"; $bankHols[] = "$yr-12-28"; break; case 0: $bankHols[] = "$yr-12-26"; $bankHols[] = "$yr-12-27"; break; default: $bankHols[] = "$yr-12-25"; $bankHols[] = "$yr-12-26"; } // Millenium eve if ($yr == 1999) { $bankHols[] = "1999-12-31"; } return $bankHols; } ?> <script> function cal_prev(mon,yr,id) { if (mon==1) { mon=12; yr--; } else mon--; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } function cal_next(mon,yr,id) { if (mon==12) { mon=1; yr++; } else mon++; document.frm_cal_sm.action="tarifs.php?mon="+mon+"&yr="+yr; document.frm_cal_sm.submit(); } </script> <form name="frm_cal_sm" method="post"> <table width="247" border="0" cellpadding="0" cellspacing="0" bgcolor="#AA0F61"> <!--DWLayoutTable--> <tr> <? $month_curr=date("n"); if($month!= $month_curr) { ?> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_prev(<?=$month?>,<?=$year?>)" class="cal_normal_sm"><</a></td> <? }?> <td width="212" height="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><? $ref= $year.'-'.$month.'-'.$date; echo $ref; ?></td> <td width="35" align="center" valign="middle" bgcolor="#EB208C" class="cal_font_month" style="background-image:url(images/navigationbg.jpg);"><a href="javascript:cal_next(<?=$month?>,<?=$year?>)" class="cal_normal_sm">></a></td> </tr> <tr> <td height="226" colspan="3" valign="top" bgcolor="#EB208C"><? DisplayCalender($id,$month,$year); ob_end_flush(); ?></td> </tr> </table> </form> </body> </html> it is really an urgent. please helo in this regard thank you Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359884 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 erm.. ok the problem seams to be here <?php $query="select holiday_date from voyance_holidays where holiday_reservationtype='Telephone Reservation'"; //echo $query; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { //$d=$year."-".$month."-".$i; $string=$row['holiday_date']; $pieces=explode("-",$string); if($i==$pieces[2]) { $class_bg="cal_font_holiday"; } else { $class_bg="cal_font_current"; } }?> i'll explain, as you loop throught the records, $class_bg will only be set to the LAST records, as its a loop i assume that the request find a set.. so what you need to do, is change it to something like to something like this <?php $query="select holiday_date from voyance_holidays where holiday_reservationtype='Telephone Reservation'"; //echo $query; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { //$d=$year."-".$month."-".$i; $string=$row['holiday_date']; $pieces=explode("-",$string); if($i==$pieces[2]) { $class_bg[$i]="cal_font_holiday"; } else { $class_bg[$i]="cal_font_current"; } }?> then change the TWO uses below from class=".$class_bg." to class=".$class_bg[$i]." Please Note i only skimmed the code and it does need cleaning up, also "urgent" work should be posted in the freelance section with an offer , free help you have to wait for Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359887 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Author Share Posted October 2, 2007 thanks but the code is still not working. color of all the dates are changing Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359892 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 add $class_bg[$i]=""; above the while($row=mysql_fetch_array($result)) so $class_bg[$i]="";//your standard class for dates while($row=mysql_fetch_array($result)) Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359894 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Author Share Posted October 2, 2007 dont i have to make changes in the place where i have echoed the calender dates? it is still not changing Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359902 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 Yes.. then change the TWO uses below from class=".$class_bg." to class=".$class_bg[$i]." Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359903 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Author Share Posted October 2, 2007 yes i exactly did like this but i think there r errors in other parts also as the calender is not changing thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359908 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 well their a few bug but your need to give some more detail as a note the most common problem i see here is.. echo "<td class=".$date_class."> should be echo "<td class='".$date_class."'> you need to quote the class names try viewing source and check to see if the class is being set Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359911 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Author Share Posted October 2, 2007 do i have to change in this part of code? $string=$row['holiday_date']; is it overlapping the looping value? Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359927 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 i'm not sure what your asking.. i assume that the holiday_date field stores the date as year-month-day you may have problems with the day if the day is 03 instead of 3.. Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359933 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Author Share Posted October 2, 2007 yes i have checked the database too. the date format is also exactly in the same format of 03. thanks Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359935 Share on other sites More sharing options...
MadTechie Posted October 2, 2007 Share Posted October 2, 2007 try this if statement $dayno = (int)$pieces[2]; if($i==$dayno) Quote Link to comment https://forums.phpfreaks.com/topic/71488-changing-css-in-the-calender-dateurgent/#findComment-359946 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.