Please help me check if the code is optimal (css moved to .css file)
Laither i will conect it to mysql and draw down my work time and calculate month total work time.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.date_0 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.date_1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #CCCCCC;
}
.date_2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #FFCCFF;
}
.date_today {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #00FFFF;
}
.mth_year {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
text-align: center;
font-weight: bold;
}
.today_top {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
text-align: center;
background-color: #FFFFFF;
}
.note {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
a {
text-decoration: none;
}
-->
</style>
</head>
<body>
<?php
// DAY NAMES
$day[0]="S";
$day[1]="M";
$day[2]="T";
$day[3]="W";
$day[4]="T";
$day[5]="F";
$day[6]="S";
// MONTH NAMES
$mth[1]="Januari";
$mth[2]="Februari";
$mth[3]="Mars";
$mth[4]="April";
$mth[5]="Maj";
$mth[6]="Juni";
$mth[7]="Juli";
$mth[8]="Augusti";
$mth[9]="September";
$mth[10]="October";
$mth[11]="November";
$mth[12]="December";
// Get todays number
$today_date = date("j", time());
$today_month = date("m", time());
$today_month_int = intval ($today_month);
$today_year = date("Y", time());
// NUMBER OF DAYS IN MONTH
$days_in_month = mktime (0,0,0,$month+1,0,$year);
$days_in_month = (strftime ("%d",$days_in_month));
// ON WHAT DAY DOES THE FIRST FALL
$day_index = date ("w", mktime(0,0,0,$month,0,$year));
// SET MONTH NAME
$month=intval($month);
$month_name = $mth[$month];
/* // ---------------- SHOW THE DATA ------------------------------------
// DATE TO DAY
echo "
today_date = $today_date <br>
today month = $today_month <br>
today_month_int = $today_month_int <br>
today_year = $today_year <p>";
echo "In this month it is $days_in_month days <br>";
echo "Månad = $month, År = $year <br>";
$start_day_temp = $day_index + 1;
echo "month start day = $start_day_temp > $day[$start_day_temp]<br>";
echo "month_name = $month_name <br>";
echo "<br><br>";
// ---------------------------------------------------- */
?>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="center" bgcolor="#FFFF99"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<?php
// previus month
$p_month = $month -1;
$p_year = $year;
if ($p_month < 1) {
$p_month = 12;
$p_year = $year -1;
}
?>
<!-- Display previus month -->
<td class="mth_year"><?php echo "<a href=\"calendar.php?month=$p_month&year=$p_year\"><<"; ?></a></td>
<!-- Display today date -->
<td class="today_top"><?php echo "<a href=\"calendar.php?month=$today_month_int&year=$today_year\">$today_date $mth[$today_month_int] $today_year"; ?></a></td>
<!-- Display actual month / year -->
<td class="mth_year"><?php echo "$month_name ($month) - $year"; ?> </td>
<?php
// Next month
$n_month = $month +1;
$n_year = $year;
if ($n_month == 13) {
$n_month = 1;
$n_year = $year +1;
}
?>
<td class="mth_year"><?php echo "<a href=\"calendar.php?month=$n_month&year=$n_year\">>>"; ?></a></td>
</tr>
<tr>
<td><img src="images/spacer.gif" width="50" height="1"></td>
<td><img src="images/spacer.gif" width="135" height="1"></td>
<td><img src="images/spacer.gif" width="380" height="1"></td>
<td><img src="images/spacer.gif" width="50" height="1"></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFF99"><img src="images/dat.gif" width="50" height="15"></td>
<td align="center" bgcolor="#FFFF99"><img src="images/day.gif" width="65" height="15"></td>
<td bgcolor="#FFFF99"><img src="images/spacer.gif" width="500" height="1"></td>
</tr>
<?php
$date_index = 0;
while ($date_index < $days_in_month) {
$date_index++;
$day_index++;
if ($day_index < 7) { // sunday
$class = "date_0";
if ($date_index == $today_date and $month == $today_month_int and $year == $today_year){
$class = "date_today";
} }
if ($day_index == 6) { // Saturday
$class = "date_1";
if ($date_index == $today_date and $month == $today_month_int and $year == $today_year){
$class = "date_today";
} }
if ($day_index == 7) { // Weekday
$day_index = 0;
$class = "date_2";
if ($date_index == $today_date and $month == $today_month_int and $year == $today_year){
$class = "date_today";
} }
echo "
<tr>
<td class=$class align=\"center\">$date_index</td>
<td class=$class><a href=\"data.php?date=$date_index&month=$month&year=$year\">$day[$day_index]</a></td>
<td class=$class>
</td>
</tr>
";
}
?>
</table>
</body>
</html>