--- a/displayConsultancies.php +++ b/displayConsultancies.php @@ -10,20 +10,23 @@ */ include_header("Consultancies"); -$query = "SELECT value, procurementMethod -FROM `contractnotice` -GROUP BY procurementMethod "; +$query = ' +SELECT SUM(value) as value, count(*), min("supplierName"), unnest(string_to_array("consultancyReason",\';\')) reason +FROM contractnotice where ' .$yearQ . ' "consultancy" = \'Yes\' and "childCN" is null +GROUP BY "supplierABN",reason order by value desc + '; -$result = mysql_query($query); + $query = $conn->prepare($query); + $query->execute(); + databaseError($conn->errorInfo()); echo ""; -while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { + foreach ($query->fetchAll() as $row) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row[0]),2); - echo (""); + echo (""); } echo "
{$row[1]}\$$value
{$row[2]}{$row[3]}{$row[1]} contracts\$$value
"; -mysql_free_result($result); include_footer(); ?>