hello,
I have written some code for it but it's not displaying date's in <td>
where is the problem can any body tell me.
<?php
//Get year 2008
$year = date('Y');
echo "Year $year</br>";
//get month
$month = date('n');
echo "Month $month</br>";
//get day
$day = date('j');
echo "Day $day</br>";
//get no of days in month
$daysInMonth = date('t',mktime(0,0,0,$month,1,$year));
echo "Days in Month $daysInMonth</br>";
//get first day of the month
$firstDay = date('w',mktime(0,0,0,$month,1,$year));
echo "First Day of Month $firstDay</br>";
//Calculate total no's of cell needed
$tempDays = $firstday + $daysInMonth;
echo "Temp days $tempDays</br>";
//Calculate total rows needed
$weeksInMonth = ceil($tempDays/7);
echo "Weeks in month $weeksInMonth</br>";
//filling the values in 2-d array
//function
function fillArray()
{
// create a 2-d array
for($j=0;$j<$this->$weeksInMonth;$j++)
{
for($i=0;$i<7;$i++)
{
$counter++;
$this->$week[$j][$i] = $counter;
// offset the days
$this->$week[$j][$i] -= $this->$firstDay;
if (($this->$week[$j][$i] < 1) || ($this->$week[$j][$i] > $this->$daysInMonth))
{
$this->$week[$j][$i] = "";
}
}
}
}
?>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> Calendar 2008 </title>
<meta name="generator" content="editplus">
<meta name="author" content="">
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<form name="f1" id="f1" method="post">
<center>Month : <select name="cboMonth">
<?php
for($m=1;$m<=12;$m++)
{
echo '<option value="'. $m .'">' . $m. '</option>';
}
?>
</select>
Year : 2008
</center>
</form>
<table border="1" cellpadding="2" cellspacing="2" align="center" width="400">
<th colspan='7'><?= date('M', mktime(0,0,0,$month,1,$year)).' '.$year; ?></th>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<?php
foreach ($week as $key => $val)
{
echo '<tr>';
for ($i=0;$i<7;$i++)
{
echo '<td align="center">'. $date .'</td>';
}
echo '</tr>';
}
?>
</table>
</body>
</html>