--- a/displayContract.php
+++ b/displayContract.php
@@ -1,21 +1,120 @@
-";
-while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
-setlocale(LC_MONETARY, 'en_US');
-$value = number_format(doubleval($row['value']),2);
-echo(print_r(array_filter($row),true));
-}
-echo "";
-echo ' View original record @ tenders.gov.au';
-
-mysql_free_result($result);
-include_footer();
+prepare($query);
+$query->bindParam(":CNID", $_REQUEST['CNID']);
+$query->execute();
+$contractResult = $query->fetch(PDO::FETCH_ASSOC);
+if (!$contractResult) {
+ header("Status: 404 Not Found");
+ header("HTTP/1.0 404 Not Found");
+include_header("Contract Not Found");
+ echo "
No Contract Notice with that ID found
";
+databaseError($conn->errorInfo());
+} else {
+$description = ucsmart($contractResult["description"]);
+include_header($description);
+ echo ''.$description.'
+ ';
+
+/*$query = $solr_client->createMoreLikeThis();
+
+$query->setQuery('id:'.$_REQUEST['CNID']);
+$query->setMltFields('description');
+$query->setMinimumDocumentFrequency(1);
+$query->setMinimumTermFrequency(1);
+$query->setInterestingTerms('description');
+$query->setMatchInclude(true);
+
+// this executes the query and returns the result
+$resultset = $solr_client->select($query);
+
+// display the total number of documents found by solr
+echo 'Found '.$resultset->getNumFound(). ' similar results: ';
+
+
+foreach ($resultset as $row) {
+setlocale(LC_MONETARY, 'en_US');
+ $value = number_format(doubleval($row['value'][0]), 2);
+ echo ("
+ {$row['id']} |
+ {$row['description'][0]} |
+ \$$value | {$row['agencyName'][0]} |
+ {$row['contractStart'][0]} |
+ {$row['supplierName'][0]} |
+
");
+}
+echo "
";*/
+
+
+$query = 'SELECT * FROM heuristic_results where "CNID" = :CNID';
+$query = $conn->prepare($query);
+$agencyName = $input . '%';
+$query->bindParam(":CNID", $_REQUEST['CNID']);
+$query->execute();
+databaseError($conn->errorInfo());
+foreach ($query->fetchAll() as $r) {
+ echo "{$r['heuristic_name']}: {$r['heuristic_value']} (raw value: {$r['raw_value']}, mean: {$r['mean']}, stddev: {$r['stddev']})
";
+}
+}
+include_footer();
?>
+