here is the search files
-----------------------------------------
search.php
------------------------------------------
<html>
<head>
</head>
<body>
<form action="check_database.php" METHOD="POST" enctype="multipart/form-data" >
<label>Title</label>
<INPUT TYPE="text" NAME="title"><br>
<label>Author</label>
<INPUT TYPE="text" NAME="author"><br>
<label>Publisher</label>
<INPUT TYPE="text" NAME="publisher"><br>
<br>
<td><INPUT class="boldit" name="submit" TYPE="submit" value="Submit"></td>
<td><INPUT class="boldit" name="reset" TYPE="reset" value="Reset"></td>
</form>
</body>
</html>
---------------------------------------------------------------------------------
checkdatabase.php CHANGE THE USERNAME AND HOST A TOP OF THIS
---------------------------------------------------------------------------------
<?php
MySQL_connect("localhost", "root"
;
MySQL_select_db("library_bank"
;
$title_search= $_POST['title'];
if (trim($title_search)!='')
{
$title_searchwords = explode(" ","$title_search"
;
foreach ($title_searchwords as $word)
{$title_searchstring= $title_searchstring.' +'.$word;}
$title_query=" MATCH(title) AGAINST ('$title_searchstring' IN BOOLEAN MODE)";
$join1=' && ';
}
else {$join1='';}
$author_search= $_POST['author'];
if (trim($author_search)!='')
{
$author_searchwords = explode(" ","$author_search"
;
foreach ($author_searchwords as $word)
{$author_searchstring= $author_searchstring.' +'.$word;}
$author_query=" MATCH(author) AGAINST ('$author_searchstring' IN BOOLEAN MODE)";
$join2=' && ';
}
else {$check2='1';$join2='';}
$publisher_search= $_POST['publisher'];
if (trim($publisher_search)!='')
{
$publisher_searchwords = explode(" ","$publisher_search"
;
foreach ($publisher_searchwords as $word)
{$publisher_searchstring= $publisher_searchstring.' +'.$word;}
$publisher_query=" MATCH(publisher) AGAINST ('$publisher_searchstring' IN BOOLEAN MODE)";
}
else {$join2='';
if ($check2=='1'){$join1='';}
}
$query = ("SELECT * from book where ".$title_query.$join1.$author_query.$join2.$publisher_query);
$result = MySQL_query($query);
if(!$result) {echo MySQL_error()."<br>$query<br>";}
if(MySQL_num_rows($result) > 0)
{
echo "<table border=1 >";
echo "<tr><td>Title </td><td>Author</td><td>Publisher</td></tr>";
while($row = MySQL_fetch_array($result))
{ echo "<td>{$row['title']}</td>";
echo "<td>{$row['author']}</td>";
echo "<td>{$row['publisher']}</td></tr>";
}
echo "</table>";}
else {echo "No Results were found.<br>";}
echo "<br>";
?>
<a href='search.php'>GO BACK TO SEARCHPAGE</A>
-----------------------------------------------------------------------------------------------
I know this second file may look daunting! even impossible to follow but it allows u to search as well as u want. you can search for any or all terms. you can type in the title word in any order, or authors surname in any order. ]
Your table in mysql needs to be using the ISAM engine and full text support enabled
need any help just ask
Edited 1 time(s). Last edit at 02/21/2008 12:19PM by stevenmartin99.