Hey everyone,
I created a fulltext search engine that will search authors of journal articles. It works great; however, it doesn't seem to search for all authors. For example, I can retrieve an article that has authors Jim, Bob, and Susan using Bob or Susan as the search term, but as soon as I use Jim I get no results. I don't know what to make of it. Also if I include a second column to be searched (i.e., year, pages, journal title< etc...) I get no results. Eventhough I converted them all to fulltext. Here is the code I am using:
<?php
$username = "username";
$password = "password";
$searchterm = $_POST['searchterm'];
if (!$searchterm) {echo "Please enter a search term."; exit;}
@ $db = mysql_connect ("server", $username, $password);
if (!$db) {echo "Unable to connect to server. Try again later."; exit;}
$connect = mysql_select_db("publications");
if (!$connect) {echo "Unable to connect to database. Try again later."; exit;}
$query = "SELECT * FROM pub_entries WHERE MATCH (author) AGAINST ('%".$searchterm."%')";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Results found for: ".$num_results." $searchterm</p>";
echo $query;
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong>" .($i+1). ". Author(s): ";
echo htmlspecialchars (stripslashes($row["author"]));
echo "</strong><br>Year: ";
echo htmlspecialchars (stripslashes($row["year"]));
echo "<br>Title: ";
echo htmlspecialchars (stripslashes($row["title"]));
echo "<br>Journal: ";
echo htmlspecialchars (stripslashes($row["journal"]));
echo "<br>Volume(issue): ";
echo htmlspecialchars (stripslashes($row["volume_issue"]));
echo "<br>Pages: ";
echo htmlspecialchars (stripslashes($row["pages"]));
echo "<br>Abstract: ";
echo htmlspecialchars (stripslashes($row["abstract"]));
echo "<br>Keywords: ";
echo htmlspecialchars (stripslashes($row["keywords"]));
echo "</p>";
}
?>