I’m trying to develop a search feature using MySQL’s ‘Full-Text’ searching capabilities.
I have a table set up, with 5 columns:
student_id - int
course_id - int
first_name - text
last_name - text
description - text
phpMyAdmin is showing that I have a primary index set up, as well as a “FULLTEXT” index set up for the fields “first_name”, “last_name” and “description”.
However, when I try and perform a simple search such as:
<?php
require_once("connection.php");
$query = "SELECT * FROM `students` WHERE MATCH(`first_name`, `last_name`, `description`) AGAINST ('natalie')";
$result = mysql_query($query);
if($r = mysql_fetch_array($result)) {
while($r = mysql_fetch_array($result)) {
extract ($r);
echo $r['first_name'] . "<br />";
echo $r['last_name'] . "<br />";
echo $r['student_id'] . "<br />";
}
} else {
echo mysql_error();
}
?>
I only recieve one result. It is a correct result, but I know there is more than one match for this search.
Can anybody help?