Location: PHPKode > projects > Network Asset Management Archive > nama/redcounts.php
<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";

$now = date("j/m/y h:i:s",time());
echo '<body bgcolor="#FFFFCC">';

$stmt2 = "Select count(a.ip_address) as counttotal, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (S.LAB = L.SERIAL) AND (S.SUBNET = A.SUBNET) and (s.lab<16) group by l.lab";
//echo $stmt . '<br>';
echo '<table width="500" border="2">';
$sth2 = ibase_query($dbh, $stmt2);
$i = 0;
$totalmachines=0;
$totalreds=0;
echo '<tr><th>Lab</th><th>Machines</th><th>Complete</th><th>Incomplete</th><th>% Complete</th><th>% Incomplete</th></tr>';
while ($row2 = ibase_fetch_object($sth2)) {
$stmt = "Select count(a.ip_address) as countred, l.lab FROM  ARP_TABLE a, SUBNETS s, LAB l, OWNER o WHERE  (L.LIASO = O.SERIAL) AND (s.LAB=L.SERIAL) and (L.LAB = '" . $row2->LAB . "') and(S.LAB = L.SERIAL) AND (S.SUBNET = A.SUBNET) and ((owner is null) or (building is null) or (room is null) or (barcode is null) or (os is null)) and (s.lab<16) group by l.lab";
$sth = ibase_query($dbh, $stmt);
$row = ibase_fetch_object($sth);
$totalmachines=$totalmachines + $row2->COUNTTOTAL;
$totalreds=$totalreds + $row->COUNTRED;
echo '<tr>';
echo '<td>' . $row2->LAB  . '</td>' ;
echo '<td>' . $row2->COUNTTOTAL . '</td>';
echo '<td>' . ($row2->COUNTTOTAL - $row->COUNTRED) . '</td>';
echo '<td>' . $row->COUNTRED . '</td>';
echo '<td>' . round((($row2->COUNTTOTAL - $row->COUNTRED) / $row2->COUNTTOTAL * 100),2) . '</td>';
echo '<td>' . round(($row->COUNTRED / $row2->COUNTTOTAL * 100),2) . '</td>';
echo '</tr>';
}
echo '<tr bgcolor="#FFFFAA">';
echo '<td><b>Total</b></td>' ;
echo '<td>' . $totalmachines . '</td>';
echo '<td>' . ($totalmachines - $totalreds) . '</td>';
echo '<td>' . $totalreds . '</td>';
echo '<td>' . round((($totalmachines - $totalreds) / $totalmachines * 100),2) . '</td>';
echo '<td>' . round(($totalreds / $totalmachines * 100),2) . '</td>';

echo "</table>";
?>

Return current item: Network Asset Management Archive