Key Ledger";
// count the keys in the table
$keyCountQuery = "SELECT COUNT(id) AS numkeys FROM key_ledger WHERE label IS NOT NULL";
$result = mysql_query($keyCountQuery) or die ("Error, key count query failed");
list($keyCount) = mysql_fetch_row($result);
echo "$keyCount keys
";
// try to display all data in this many tables
// later arrange these tables in 'meta' columns
$numTables = 3;
// count the number of rows in the key ledger table
$rowCountQuery = "SELECT COUNT(id) AS numrows FROM key_ledger";
$result = mysql_query($rowCountQuery) or die ("Error, row count query failed");
list($rowCount) = mysql_fetch_row($result);
// show the whole key ledger table
$query = "SELECT id,label,type,serial FROM key_ledger";
$result = mysql_query($query);
// make as many tables as requested,
// but no more than there are rows of data
for ($i=0; $i';
echo '';
echo "| id | " .
"label | " .
"type | " .
"serial | ";
// for each table, print an equal portion of the data
while(($printedRows < ($rowCount/$numTables)) &&
(list($id,$label,$type,$serial) = mysql_fetch_row($result)) ) {
$printedRows++;
echo "" .
"| $id | " .
"$label | " .
"$type | " .
"$serial | " .
// "$printedRows | " .
"
";
}
echo "
";
// end of this div
echo '';
}
// free query memory
mysql_free_result($result);
// close the db connection
include 'closedb.php';
?>