Jump to content

changing css in the calender date(urgent)


localhost1

Recommended Posts

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

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.