Jump to content

need help to compare dates in loops


waqas47

Recommended Posts

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....

plz 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,leave_status,leave_comments,leave_type_id 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_row($res, MYSQL_NUM)) {
                 $time2=date("Y-n-j",strtotime ($row[0])).'<br/>';
                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

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.