Anyone know how to do two things (or help me look in the right direction):
1) add a blank table column to either the beginning or the end of my code below?
2) change the cells of the blank table columns dependent on numerical data within each specific row?
Help if you can......
Okay...here's what I have so far:
<html>
<head>
<title>Network Check!</title>
<meta http-equiv="refresh" content="30;URL=http://localhost/netcheck2.php">
</head>
<?PHP
mysql_connect("localhost", "root");
mysql_select_db("netcheck");
mysql_query("LOAD DATA INFILE 'getfile.txt' REPLACE INTO TABLE nets
LINES TERMINATED BY '|'");
?>
<?php
$dbname = "netcheck";
$loginname = "root";
$loginpass = "";
$dbhost = "localhost";
echo('<html><body bgcolor="#FFFFFF">');
echo('<font face="arial" size="+2"><b><center>');
echo("Database $dbname </b>");
$id_link = @mysql_connect($dbhost, $loginname, $loginpass);
$tables = mysql_list_tables($dbname, $id_link);
$num_tables = mysql_num_rows($tables);
// store table names in an array
$arr_tablenames[] = '';
// store number of fields per table(index 0,1,2..) in an array
$arr_num_fields[] = '';
for ($i=0; $i < $num_tables; $i++) {
$arr_tablenames[$i] = mysql_tablename($tables, $i);
$arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link));
}
// store field names in a multidimensional array:
// [i] == table number, [ii] == field number for that table
for ($i=0; $i < $num_tables; $i++) {
for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
$result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
$hash_field_names[$i][$ii] = mysql_field_name($result, $ii);
}
}
for ($i=0; $i < $num_tables; $i++) {
echo("<center><h3>Table $arr_tablenames[$i] </h3></center>");
echo('<table align="center" border="1"><tr>');
$result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
echo("<th>");
echo $hash_field_names[$i][$ii];
echo("</th>");
}
echo("</tr><tr>");
$number_of_rows = @mysql_num_rows($result);
for ($iii = 0; $iii < $number_of_rows; $iii++) {
$record = @mysql_fetch_row($result);
for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
echo("<td>");
echo $record[$ii];
echo("</td>");
}
echo("</tr>");
}
echo("</table>");
}
echo('</body></html>');
?>
<br>
<font size="2"><b> Notes </b><br>
getfile.txt is located in /mysql/data/netcheck/ ...or location of data<br>
page currently refreshes every 30 seconds<br><br>
<b>Need to show this:</b><br>
<b>Green=</b><br>
Less 1% error all links<br>
Less 5% Bandwidth Util.<br>
Less 25% CPU Util.<br>
100% Connectivity<br><br>
<b>Yellow=</b><br>
2% error- 5% (<i>Email WAN list)</i><br>
30 sec. loss of conn. <i>(none)</i><br>
(clears after 5 min.)<br>
+ 5% Bandwidth Util. <i>(Email WAN list)</i><br>
+ 25% CPU Util. <i>(Email WAN list)</i><br><br>
<b>Red=</b><br>
6% or higher error <i>(Email - x3 every (300sec) & page)</i><br>
30 sec loss x2 under (5 min) <i>(Flash)</i><br>
+10% Bandwidth Util. <i>(Audible Alarm)</i><br>
+50% CPU Util<br></font>
</body>
</html>
the getfile text is tab-delimited (here's a sample):
5 Net 5 Bldg 25 2 0 2 100|
1 Net 1 Bldg 26 10 5 8 100|