function showSystems($result, $i, $byCompany)
{
$key = pg_fetch_result($result, $i, "key");
$title = pg_fetch_result($result, $i, "title");
$updated = pg_fetch_result($result, $i, "updated");
// get the updated date and current date so we can see if
// we need to add an updated gif to the entry.
$month = intval(substr($updated, 5, 2));
$day = intval(substr($updated, 8, 2));
$year = intval(substr($updated, 0, 4));
$today = getdate();
$monthNow = $today['mon'] + 12 * ($today['year'] - $year);
print("$title");
// if the last update was within a month, add the updated gif
if ($monthNow - $month == 0 || ($monthNow - $month == 1 && $today[mday] <= $day))
{
print(" ");
}
print(" \n");
}
$dbconnect = pg_connect("dbname=trailingedge user=dlw");
$query = "SELECT COUNT(*) FROM wantedcomps";
$result = pg_query($dbconnect, $query);
$sysCount = pg_fetch_result($result, 0, 0);
print("");
print("\n| ");
print(" Wanted Stats: $sysCount systems and growing. ");
if (isset($_GET['byCompany']))
$byCompany = $_GET["byCompany"];
else
$byCompany = 0;
print("");
if ($byCompany)
{
print("Sort by system \n");
print("Intro \n");
$query = "SELECT s.key, s.title, s.updated, c.name FROM";
$query .= " wantedcomps s, company c WHERE c.id = s.company ";
$query .= "ORDER BY c.name, s.key";
$result = pg_query($dbconnect, $query);
$oCompanyName = "";
$numComps = pg_num_rows($result);
for ($companyRow = 0; $companyRow < $numComps; $companyRow++)
{
$companyName = pg_fetch_result($result, $companyRow, 3);
if ($companyName != $oCompanyName)
print("$companyName\n");
showSystems($result, $companyRow, 1);
$oCompanyName = $companyName;
}
}
else
{
print("Sort by company \n");
print("Intro \n");
$query = "SELECT key, title, updated FROM wantedcomps ORDER BY key";
$result = pg_query($dbconnect, $query);
$numRows = pg_num_rows($result);
for ($i = 0; $i < $numRows; $i++)
showSystems($result, $i, 0);
}
print("");
pg_free_result($result);
pg_close($dbconnect);
print(" | \n \n \n");
?>
|
|
include("/home/dlw/public_html/comp/wintro");
?>
|
|