I am putting together a simple search system for a bank of articles from a student scientific event. By adapting codes from some guides that I found on the internet the system is running all right. The only problem is that it only returns results with exact words.
For example: If I want to return an article that talks about Information Organization and search for "Information Organization", the system returns nothing. The user needs to by exactly searching "Information Organization".
I found a topic here in the Stack that seems to contain the solution to the problem in the answers, however, I could not apply it to my system. Follow the link: Search with LIKE or MATCH..AGAINST in two columns
I ask you to analyze my code and help me, if possible, how to fit the tips in my system or if you have a better way, please give me a light.
Here is the PHP code I'm using for the search (I've removed only the paging codes from the results):
<?php
// A busca
$busca = $_GET['consulta'];
$busca = mysql_real_escape_string($busca);
$sql = "SELECT * FROM 'artigos' WHERE ('ativa' = 1) AND (('titulo' LIKE '%".$busca."%') OR ('resumo' LIKE '%".$busca."%') OR ('%".$busca."%')) ORDER BY 'grupo' DESC LIMIT ".$inicio.", ".$_BS['PorPagina'];
// Executa a consulta
$query = mysql_query($sql);
// Mostra resultados
echo "<ul>";
while ($resultado = mysql_fetch_assoc($query)) {
$titulo = $resultado['titulo'];
$resumo = $resultado['resumo'];
$link = 'http://meusite.com.br/artigos/' . $resultado['link'];
echo "<li>";
echo '<a href="'.$link.'" title="'.$titulo.'">'.$titulo.'</a><br />';
echo "<p>";
echo '<p>'.$resumo.'</p>';
echo "</li>";
}
echo "</ul>";
?>
Thanks in advance for your help.
Hugs!