Sean, I'm not sure if I correctly understand what you want so if this is off the mark feel free to dump it in the trash.
It sounds like a vacation planner. If that is what it is then for the db you you need:
TABLE_requests:
employee_id int(5) // or what ever format you have now for IDs
year_month int(4)
request_mask char(31) default "1111111111111111111111111111111"
/* any other columns you want to associate with the request.
The primary key is employee_id, year_month and an index on year month is handy
For a request for a given month the sql is simple:
select * from TABLE_requests
where year_month = $yearmonth
order by employee_id;
The request mask is a string where each byte is one or two. One they are in the office or two they are on holiday. For the output you just create two CSS class to present a differnt look for the two states. You can then generate the cells for the month by looping for the number of days in the given month:
$dayArray = str_split($request_mask);
for ($i=1 $i<=$daysinmonth;$i++)
{
$cls=($dayArray[$i-1]%2) ? 'inOffice' : 'holiday';
print '<td class="'.$cellclass.'"> </td>';
}
str_split() is PHP5, so if you are on < PHP5 you can add this code to create a function that returns the same array.
if (!function_exists("str_split")) {
function str_split($str,$length = 1) {
if ($length < 1) return false;
$strlen = strlen($str);
$ret = array();
for ($i = 0; $i < $strlen; $i += $length) {
$ret[] = substr($str,$i,$length);
}
return $ret;
}
}
However if you are looking for something different let me know.
:^)
Cd&