function showSystems($result, $i, $byCompany)
{
$key = pg_fetch_result($result, $i, "key");
$title = pg_fetch_result($result, $i, "title");
$count = pg_fetch_result($result, $i, "count");
$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 ($count > 1)
print(" (x$count)");
print("");
/* 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");
}
/******************************************************************************/
/* main body */
/******************************************************************************/
$query = "SELECT SUM(count), COUNT(*) FROM systems";
$result1 = pg_query($dbconnect, $query);
$sysCount = pg_fetch_result($result1, 0, 0);
$modCount = pg_fetch_result($result1, 0, 1);
print("");
print("\n| ");
print(" Collection Stats: $sysCount systems $modCount models ");
if ($byCompany)
{
print("Sort by system \n");
print("");
print("Intro \n");
$query = "SELECT s.key, s.title, s.count, s.updated, c.name FROM";
$query .= " systems s, company c WHERE c.id = s.company ";
$query .= "ORDER BY c.name, s.key";
$result1 = pg_query($dbconnect, $query);
$oCompanyName = "";
$numComps = pg_num_rows($result1);
for ($companyRow = 0; $companyRow < $numComps; $companyRow++)
{
$companyName = pg_fetch_result($result1, $companyRow, 4);
if ($companyName != $oCompanyName)
print("$companyName\n");
showSystems($result1, $companyRow, $byCompany);
$oCompanyName = $companyName;
}
}
else
{
print("Sort by company \n");
print("Intro \n");
$query = "SELECT key, title, count, updated FROM systems ORDER BY key";
$result1 = pg_query($dbconnect, $query);
$numRows = pg_num_rows($result1);
for ($i = 0; $i < $numRows; $i++)
showSystems($result1, $i, $byCompany);
}
pg_free_result($result1);
print(" | \n \n \n");
?>
|
if ($image == "")
{
print("| ");
}
else
{
print(" |  | ");
}
?>
print("$title"); ?> |
| Updated print($updated); ?> |
|
|
for ($index = 0; $index < 8; $index++)
{
print("| ");
print("$rowNames[$index] : | ");
if ($rowNames[$index] == "CPU")
{
$query = sprintf("SELECT name, bitsize FROM cpu WHERE id = %d or id = %d or id = %d", $rowData["CPU"], $cpu2, $cpu3);
$doneOne = 0;
$aResult = pg_query($dbconnect, $query);
$numRows = pg_num_rows($aResult);
for ($cpus = 0; $cpus < $numRows; $cpus++)
{
$cpuName = pg_fetch_result($aResult, $cpus, 0);
if ($cpuName == "None")
continue;
if ($doneOne == 1)
print("/");
print($cpuName);
$doneOne = 1;
$bitsize = pg_fetch_result($aResult, $cpus, 1);
if ($bitsize != 0)
print(" ($bitsize Bit)");
}
if ($doneOne == 0)
print("None");
}
elseif ($rowNames[$index] == "Company/Released")
{
$query = sprintf("SELECT name FROM company WHERE id = %d", $rowData[$rowNames[$index]]);
$aResult = pg_query($dbconnect, $query);
print(pg_fetch_result($aResult, 0, 0));
}
else
{
print($rowData[$rowNames[$index]]);
}
print(" | \n");
}
?>
Comments
Related Links
pg_free_result($result);
pg_close($dbconnect);
?>
|