Let me make sure I understand what you want to do. Right now, the Facility header is in the table, as its own distinct TR, and you want it to be moved out of the table? so your structure would become multiple tables each with a Facility header?
if thats what you want, just move the table declaration into the loop, and use multiple tables.
// first set some basic vars:
$label = "";
$type = "";
$data = "";
$allocation = '';
$diff = '';
include ("UpLoad/connect.php");
//load it all into the associative array
$sql = "select * from dbo.vwAllByFacility";
$result = mssql_query($sql);
echo $type;
while($row = mssql_fetch_row($result))
{
if($row[1] <> $label)
{
if($allocation != '')
{
echo $allocation;
}
if($diff != '')
{
echo $diff;
}
//header row
echo "<span class=blue>Facility: $row[0]</span>
echo "<table border=1>";
<TR class =dkblue>
<th class=header>".$row[1]."</td>
<th>MT</th><th>Strip</th></tr>";
$label = $row[1];
//allocations row
$allocation = "<tr class=blue>".
"<td>Allocation</td>".
"<td>$row[23]</td>".
"<td>$row[24]</td>".
"<td>$row[25]</td>".
"</tr>";
//difference row
$diff = "<tr class=blue>".
"<td>Difference</td>".
"<td>$row[41]</td>".
"<td>$row[42]</td>".
"<td>$row[43]</td>".
"</tr>";
}
//data row
echo "<tr class=tr>
<td>$row[2]</td>
<td class=$mtstyle>$row[3]</TD>
<td class=$ststyle>$row[4]</td>
<td>$row[5]</td>
<td class=blue>$row[6]</td>
</tr>";
echo "</table><br>";
}
echo $allocation;
echo $diff;
is that what you were looking for?