Hi all. I am trying to get my site to be able to search for a film name.
A simple textfield that when submitted searched the database.
<?php
$serResult = NULL;
if ((isset($_POST["keywords"])) && ($_POST["keywords"] == "form1")) {
$sql = "SELECT film_name, film_genre FROM films " .
"WHERE MATCH (film_name,film_genre) " .
"AGAINST ('" . $_GET['keywords'] . "') " .
"ORDER BY MATCH (film_name,film_genre) " .
"AGAINST ('" . $_GET['keywords'] . "') DESC";
$serResult = mysql_query($sql,$conn1)
or die('Could not perform search; ' .mysql_error());
}
echo "<h1>Search Results</h1>\n";
if ($serResult and !mysql_num_rows($serResult)) {
echo "<p>No articles found.</p>\n";
} else {
while ($row = mysql_fetch_array($serResult)) {
echo ($row['film_name']);
}
}
?>
<form name="form1" method="post" action="">
<input name="keywords" type="text" id="keywords">
<input type="submit" name="Submit" value="Search">
</form>
It automatically searched when the page is loaded and doesnt wait untill the submit button is pressed.
Any ideas on why this is?
Regards