0
Good morning everyone, I didn’t know exactly how to put the title, nor how to research it.
I have a if else in PHP that says that if the result is not found at first, it will try to find a similar result by making an array with the text.
Let’s say for the example cited below my base has something like significado palavra sono and the result of that Estado caracterizado por supressão da vigília...
In this case the words da and palavra shall be located on other lines, but the line significado palavra sono will be the most localized with a total of 3 locations.
How do I rank this and display only the most localized line ?
PHP
$texto = "significado da palavra sono";
$palavras = explode(" ", $texto);
foreach($palavras as $palavra){
$sql = "SELECT * from dicionario where recebido like '%$palavra%'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()){
echo "<p>[".$palavra."]Resultado similar: ".$row['resultado']."<p>";
}
}
}
Later on I want to try to implant something about probability. Another question, is there a better way to do this ?
Thank you.
You must use the
Full-Text Search, see https://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html.– Inkeliz