1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | <?php /* search ABNs search agency name search categories search supplier names --search supplier postcodes/suburbs/cities-- search CN number search description full text */ include('./lib/common.inc.php'); if ($_REQUEST['searchID']) { $searchIDParts = explode("-", $_REQUEST['searchID']); $type = array_shift($searchIDParts); $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); if ($type == "agency") { header("Location: http://$host$uri/displayAgency.php?agency=" . implode("-", $searchIDParts)); } if ($type == "supplier") { header("Location: http://$host$uri/displaySupplier.php?supplier=" . implode("-", $searchIDParts)); } if ($type == "cnid") { header("Location: http://$host$uri/displayContract.php?CNID=" . implode("-", $searchIDParts)); } exit; } else { include_header("Search Results"); /*// get a select query instance $query = $solr_client->createSelect(); // set a query (all prices starting from 12) $query->setQuery($_REQUEST['searchKeyword']); // set start and rows param (comparable to SQL limit) using fluent interface $query->setStart(0)->setRows(100); // set fields to fetch (this overrides the default setting 'all fields') $query->setFields(array('id','description','value','agencyName','contractStart','supplierName', 'score')); // sort the results by price ascending //$query->addSort('price', $query::SORT_ASC); // 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(). ' results. <table>'; foreach ($resultset as $row) { foreach ($query->fetchAll() as $row) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['value'][0]), 2); echo ("<tr> <td><a href=\"displayContract.php?CNID={$row['id']}\">{$row['id']}</a></td> <td><b>{$row['description'][0]}</b></a></td> <td>\$$value</td><td>{$row['agencyName'][0]}</td> <td>{$row['contractStart'][0]}</td> <td>{$row['supplierName'][0]}</td> </tr>"); */ $keyword = $_REQUEST['searchKeyword']; $query = 'SELECT "CNID", "description", "value", "agencyName", "category", "contractStart", "supplierName" FROM contractnotice WHERE ' .$yearQ . ' to_tsvector(\'english\', description) @@ plainto_tsquery(\'english\', :keyword) and "childCN" is null ORDER BY "value" DESC limit 100'; $query = $conn->prepare($query); $query->bindParam(":keyword", $keyword); $query->execute(); databaseError($conn->errorInfo()); echo '<table>'; foreach ($query->fetchAll() as $row) { //print_r($row); setlocale(LC_MONETARY, 'en_US'); $value = number_format($row['value'], 2); echo ("<tr> <td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> <td><b>{$row['description']}</b></td> <td>\$$value</td><td>{$row['agencyName']}</td> <td>{$row['contractStart']}</td> <td>{$row['supplierName']}</td> </tr>"); } echo "</table>"; include_footer(); } ?> |