--- a/displayAgency.php +++ b/displayAgency.php @@ -1,42 +1,41 @@ prepare($query); -$query->bindParam(":agency", $agency); - $query->execute(); - if (!$query) { - databaseError($conn->errorInfo()); - } + ORDER BY "value" DESC limit 100'; + $query = $conn->prepare($query); + $query->bindParam(":agency", $agency); + $query->execute(); + databaseError($conn->errorInfo()); - echo " + echo "
@@ -46,46 +45,44 @@ "; - foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row['value']) , 2); - echo (" + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + echo (""); - } - echo "
Contract Notice Number Contract DescriptionSupplier
{$row['CNID']} {$row['description']} \$$value{$row['agencyName']} {$row['contractStart']} {$row['supplierName']}
"; + } + echo ""; } else { /* - split by portfolio - */ -include_header("Agencies"); -agenciesGraph(); - $query = 'SELECT SUM("value"), "agencyName" + split by portfolio + */ + include_header("Agencies"); + agenciesGraph(); + $query = 'SELECT SUM("value"), "agencyName" FROM contractnotice -WHERE "childCN" = 0 +WHERE "childCN" is null GROUP BY "agencyName" '; -$query = $conn->prepare($query); - $query->execute(); - if (!$query) { - databaseError($conn->errorInfo()); - } - echo " + $query = $conn->prepare($query); + $query->execute(); + databaseError($conn->errorInfo()); + echo "
"; - foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row[0]) , 2); - $agency = stripslashes($row[1]); - echo ("\n"); - } - echo "
Agency Total Contracts Value
{$agency}\$$value
"; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row[0]), 2); + $agency = stripslashes($row[1]); + echo ("{$agency}\$$value\n"); + } + echo ""; } include_footer(); ?>