Click here to Skip to main content
15,915,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am am making a leave calendar ...i want to compare dates and if the matches the background will be changed .
i am try to do is i got two loops first for 12 months and seconds for numbers of days in that month and i am using $num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear)
this will give be numbers of days in that month...
then there is a my sql query which will select that dates and other data from database ..
now problem i am have is that numbers of days are not increment it show date like 2011-1-1 ,2011-1-1 and so on instead of 2011-1-1, 2011-1-2....
please help me ..here
<<pre lang="xml">table >
<?php for($Month=01;$Month <= 12;) { ?>
    <tr>
        <td  width="18%"  colspan="2"><strong><?php echo $monthNames[$Month-1]; ?></strong></td>
        <td  width="12%"  colspan="2"><strong>Division</strong></td>
        <?php
        $num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear); // 31
        //$dates = date("$cYear-$Month-1");
            $sql ="SELECT leave_date FROM `hs_hr_leave` WHERE employee_id = $emplid ";
            $res = mysql_query($sql);

        for($i=1;$i<=$num;$i++)
        {   $dates = date("$cYear-$Month-$i");
            echo $dates."<br/>";
                while ($row = mysql_fetch_array($res, MYSQL_NUM)) {
                 $time2=date("Y-n-j",strtotime ($row[0])).'<br/>';
                 foreach($row as $key=>$value) {
                 }
                //echo  "<td bgcolor='red'>".$dates."--".$time2."</td>";
                //echo  "<td>".$row[1]."</td><br/>";
                //echo  "<td>".$row[1]."</td><br/>";
                //echo  "<td>".$row[2]."</td><br/>";
                                }
            //echo "<td width='26' height='20px' align='center' valign='middle' >".$i."</td>";
        }
        //echo "<br/>";
        $Month++;
    }
?>
    </tr>
</tabl

e>
Posted
Updated 14-Feb-11 17:34pm
v5
Comments
Sandeep Mewara 14-Feb-11 14:09pm    
Did you debug?
Henry Minute 14-Feb-11 16:46pm    
I don't suppose for one moment that it will help with your problem and I don't do PHP but are you sure that you want to use CAL_GREGORIAN?
vicky87 14-Feb-11 17:35pm    
yes i try my best find the problem ..but ..still got problem...
and i just found the php fucation to count days in month i dont know what CAL_GREGORIAN mean ..
Henry Minute 14-Feb-11 17:41pm    
Please ignore my comment. CAL_GREGORIAN is correct. I got muddled. :)
vicky87 14-Feb-11 18:01pm    
no problem ..thx fro reply but i need some help ..here and php exp man ...i have to give this project in 2-3 days and this is my first project ..so plx help me out here...

1 solution

Hi I am doubtful even your code run without error...

$num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear); It is following a html. So not php. You need to have a php opening like
PHP
<?php $num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear);</pre?>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900