I am trying to change the table headers to something other then the fields in the db. I am unsure where to inject it into the code. So far this is what I have:
<?php
require("user.inc");
#if (!mysql_connect($host, $user,$password)) die("You know it couldn't be that easy!");
mysql_select_db("iwar");
$result=mysql_query("SELECT * FROM Location, Company WHERE Location.TeleNumber = Company.number AND Company.response = 'Timeout'");
$num_rows = mysql_num_rows($result);
if (!$result)
{
die("Query failed to show fields from table.");
}
$fields_num = mysql_num_fields($result);
echo "<h1>$num_rows Number of Companies {$table}</h1>";
echo "<table border=\"1\", cellspacing=\"0\", cellpadding=\"4\"><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "<tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "</tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
?>
The fields for the db are;
Location
alpha_code (Change to Alpha)
LocationNumber (Change to Number)
OpComp (Change to Company)
TeleNumber (Change to Telephone Number)
Company
timestamp (Change to Time Stamp)
number (Change to Count)
response (Change to Response)
ident (Change to Identity)
As you can see the field names are some what cryptic and I want to make them easier to read.