Posted by:
stevenmartin99
(---.b-ras1.blp.dublin.eircom.net)
-------------------------------------------------------------------------------------------
<?php
$search= $_POST['search'];
$searchwords = explode(" ","$search"
;
foreach ($searchwords as $word)
{$searchstring= $searchstring.' +'.$word;}
$tablelist = array(1 => 'book', 'cdrom', 'journal');
MySQL_connect("localhost", "root"
;
MySQL_select_db("library_bank"
;
foreach ($tablelist as $table){
$query = "SELECT * from $table Where MATCH(author,title,publisher,keywords) AGAINST ('$searchstring' IN BOOLEAN MODE)";
$result=mysql_query($query);}
if(!$result){echo MySQL_error()."<br>$data<br>";}
if(MySQL_num_rows($result) > 0)
{echo "<table border=1 >";
echo "<tr><td>Author</td><td>Title</td><td>Publisher</td><td>Keywords</td></tr>";
foreach ($tablelist as $table)
{ $query = "SELECT * from $table Where MATCH(author,title,publisher,keywords) AGAINST ('$searchstring' IN BOOLEAN MODE)";
$result=mysql_query($query);
while($row = MySQL_fetch_array($result))
{ echo "<tr><td>{$row['author']}</td>";
echo "<td>{$row['title']}</td>";
echo "<td>{$row['publisher']}</td>";
echo "<td>{$row['keywords']}</td></tr>";}}
echo "</table>";
}
else {echo "No Results were found.<br>";}
echo "<br>";
?>
<a href='search.php'>back</a>
--------------------------------------------------------------------------------
please note the words author title publisher and keyword in my script are all lowercase. make sure this matches
and the table names i have in it $tablelist = array(1 => 'book', 'cdrom', 'journal');
change them again if different
all you need to do is change your tables to use MyISAM instead of INNODB
and turn on full text support
if you dunno how to do that just ask