Well I'm not quite sure how SQL server works, so I won't bother trying to type up the exact code, but what I would do is:
Change this up a bit:
echo "<td>";
echo odbc_result($result,$i);
echo "</td>";
At this part, modify the td tag to something like:
$resultfield = odbc_result($result,$i); //I'm assuming you can do this...
echo "<td class='$resultfield'>";
echo $resultfield;
echo "</td>";
Basically, this will assign each TD to a class named after the value of the field. This is a bit messy, but this way, in your CSS file, you can create .occupied and .vacant, and have them set the font color to the appropriate color. All the TDs that contain either of those values will change colors. Anything else will be ignored unless you define a class of their TD values.
Something else you could do is modify this a bit:
for($i=1;$i<=odbc_num_fields($result);$i++)
{
echo "<td>";
echo odbc_result($result,$i);
echo "</td>";
}
To make it less messy, you'd have to know which field contains the status value. According to your SQL statement, it should be the fourth field, or value "3". So...
for($i=1;$i<=odbc_num_fields($result);$i++)
{
if ($i == 3)
{
$resultfield = odbc_result($result,$i); //I'm assuming you can do this...
echo "<td class='$resultfield'>";
}
else
{
echo "<td>";
}
echo odbc_result($result,$i);
echo "</td>";
}
Again, you will have to set the .occupied and .vacant classes in CSS but those should be the only two needing to be set.