-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
25 lines (25 loc) · 788 Bytes
/
search.php
File metadata and controls
25 lines (25 loc) · 788 Bytes
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
<?php //search.php
require_once "conn.php";
require_once "outputfunctions.php";
require_once "header.php";
$result = NULL;
if(isset($_GET["keywords"])) {
$sql = "SELECT article_id FROM cms_articles " .
"WHERE MATCH (title,body) " .
"AGAINST ('" . $_GET["keywords"] . "' IN BOOLEAN MODE) " .
"ORDER BY MATCH (title,body) " .
"AGAINST ('" . $_GET["keywords"] . "' IN BOOLEAN MODE) DESC";
$result = mysql_query($sql,$conn)
or die("Couldn't perform search: " . mysql_error());
}
echo "<h1>Search Results</h1>";
if($result and !mysql_num_rows($result)) {
echo "<p>No articles found that match the terms.</p>\n";
} else {
while ($row = mysql_fetch_array($result)) {
outputStory($row["article_id"], TRUE);
}
}
mysql_close($conn);
require_once "footer.php";
?>