hi
and thanks too all people who helped me here ...AlbinAbel and jswolf19...
thanks a lot...
this is what i came up with and so far its working ...but i have a little thing to ask ...how i can check weekend ...
i have a table name weekends in database and it have two field one for day and type
day is from 1-7 representing mon-sun and other field type which can be set by admin for weekends whatever day admin likes to be as weekend ...
how i can check display as weekend which are set by admin...with background color
<pre lang="xml"><table >
<?php
while ($row = mysql_fetch_array($rest, MYSQL_NUM)) {
$request_id = $row[1];
$leave_status = $row[2];
$leave_comments = $row[3];
$leave_demp = $row[4];
$leave_type_name = $row[5];
$leave_color = $row[6];
$emp_dep = $row[7];
$dbD = date("d", strtotime($row[0]));
$dbM = date("m", strtotime($row[0]));
$dbY = date("Y", strtotime($row[0]));
$dbuser = date("Y-m-d", mktime(0, 0, 0, $dbM, $dbD, $dbY));
$userDates[$dbuser] = array('comments' => $leave_comments, 'status' => $leave_status,'color' => $leave_color,'empdep' => $emp_dep);
}
$cYear=2011;
$Months = array(1, 2, 3, 4,5,6,7,8,9,10,11,12);
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
foreach($Months as $M) { ?>
<tr>
<td width="18%" colspan="2"><strong><?php echo $monthNames[$M-1]; ?></strong></td>
<td width="12%" colspan="2"><strong><?php echo $userDates[$dbuser]['empdep'] ?></strong></td>
<?php
$num = cal_days_in_month(CAL_GREGORIAN, $M, $cYear);
$arrydats = array_fill (1,$num,"");
$i=0;
foreach($arrydats as $d)
{
$i++;
$dates = date("Y-m-d", mktime(0, 0, 0, $M,$i, $cYear));
$checkdate = strtotime($dates);
if(isset($userDates[$dates]))
{
echo "<td width='26' title='".$userDates[$dates]['comments']."' height='20px' bgcolor='#".$userDates[$dates]['color']."' align='center' valign='middle' >";
if($userDates[$dates]['status'] == -1)
{ echo "R"; }
elseif ($userDates[$dates]['status'] == 0 )
{ echo "C"; }
elseif ($userDates[$dates]['status'] == 1 )
{ echo "PA"; }
elseif ($userDates[$dates]['status'] == 2 )
{ echo "A"; }
elseif ($userDates[$dates]['status'] == 3 )
{ echo "T"; }
elseif ($userDates[$dates]['status'] == 4 )
{ echo "W"; }
elseif ($userDates[$dates]['status'] == 5 )
{ echo "SH"; }
}
else {
echo "<td width='26' height='20px' align='center' valign='middle' >".$i."</td>";
}
}
}
?>
</tr>
</tabl
e>