WS$machine
";
break;
case 1:
echo "WS$machine
 | ";
break;
default:
echo "WS$machine
 | ";
break;
}
}
# get the current time, and subtract 6 minutes
$sTime = time() - (60 * 6);
$sTimeStr = date("Y-m-d H:i:s", $sTime);
echo "Chapman Lab Status
$sTimeStr
";
echo "(This page will automatically refresh every 2 minutes)
";
#echo "SELECT * FROM wsstatus WHERE wstime>'$sTimeStr' ORDER BY wsname ASC, wstime DESC
";
echo "";
echo " | Offline |
";
echo " | In Use |
";
echo " | Free |
";
echo "
";
$link = mysql_connect(localhost, "cmonWeb", "Q9axCUm'$sTimeStr' ORDER BY wsname ASC, wstime DESC") or die("Error: 3 - " . mysql_error());;
#$rs=mysql_query("SELECT * FROM wsstatus ORDER BY wsname ASC, wstime DESC") or die("Error: 3 - " . mysql_error());;
echo "";
#to get this to display right, we've got to do a little pre-set ordering
$num=0;
$temp = 1;
while ($row = mysql_fetch_array( $rs )) {
if ($temp == $row['wsname']) {
# add a row for this workstation
if ($row['wsuser'] != "none") {
$status[$temp-1] = 1;
} else {
$status[$temp-1] = 0;
}
$temp++;
}
else if ($temp > $row['wsname']) {
# we already added a row for this workstation, so ignore this row
#echo "WS" . $row['wsname'] . " | Ignored |
";
}
else {
# some of the workstations are not reporting in
do {
$status[$temp-1] = 2;
$temp++;
} while ( $temp < $row['wsname'] );
if ($row['wsuser'] != "none") {
$status[$temp-1] = 1;
} else {
#free
$status[$temp-1] = 0;
}
$temp++;
}
}
$row = mysql_fetch_array($rs);
echo "Printer | ";
for($i = 17; $i < 20; $i++) {
displayMachine($status[$i],$i+1);
}
echo "
";
for($i = 13; $i < 17; $i++) {
displayMachine($status[$i],$i+1);
}
echo "
";
for($i = 9; $i < 13; $i++) {
displayMachine($status[$i],$i+1);
}
echo "
";
for($i = 5; $i < 9; $i++) {
displayMachine($status[$i],$i+1);
}
echo "
";
for($i = 1; $i < 5; $i++) {
displayMachine($status[$i],$i+1);
}
echo "
| | | ";
displayMachine($status[0],1);
echo "Back of Lab
";
# deal with any remaining workstations
#while ($wsnum <= 20) {
#echo "WS$wsnum | OFFLINE |
";
#$wsnum++;
#}
echo "
";
echo "Front of Lab
";
mysql_close($link);
?>