1
I have a table called boletos
, and created a FULLTEXT index for the column categoria
, which is the column that will go the most in the search for the Where.
I did everything right, only when it’s time to search, he’s not filtering the result on Where. It simply brings all the results of the table and what I sought it puts at the top of the table, and I would like it to bring only the result I sought.
I don’t know if it’s mine select which is correct, but I will post here my code.
billets:
id int auto increment
boleto mediumblob//arquivo pdf,jpeg
nomeBoleto varchar,//nome do arquivo
tipoBoleto varchar,//tipo do arquivo(.pdf ou .jpeg)
categoria varchar,//só tem 2: Pagamento Mensal e Pagamento Anual
primary key (post_id),
FULLTEXT (categoria)//indice pra pesquisar por categoria
My PHP is like this:
<?php
include "conexão.php";
//aqui puxa minha categoria do campo
$categoria = $_POST['comboB'];
//e meu select
$stmt = $db->prepare("select id,nomeBoleto,categoria from boletos WHERE MATCH (categoria) AGAINST ('$categoria' in boolean mode)");
$stmt->execute();
while($row = $stmt->fetch()){
if($row > 0){
<tr>
<td><?php echo $row['id']?></td>
<td><?php echo $row['nomeBoleto']?></td>
<td><?php echo $row['categoria']?></td>
</tr>
}
?>
It simply brings all the records putting what I sought at the top of the table, being that it is to bring only what I put to bring.
What am I doing wrong?
Put , if possible , the data.
– Motta
As well as the data?
– Joana
The data you entered and tried to search for may have an impact.
– Motta
The data I seek enters the category column, and that is in the Where of my select...in this category column only has two options that is: Monthly Payment and Annual Payment, I do not know if it influences why the words are equal.. I’ve read something about, but I can’t fix it :(
– Joana
@Motta edited the question and put in front of the columns the types of data that are entered, if you can help me.. I’m cracking my head to fix it..
– Joana
The problem may be in the data , which "category" is in the table and which category you searched ? I don’t know "fulltext" but it can be this
– Motta
In this category column only has two options that is: Monthly Payment and Annual Payment, fulltext is table mysql indices, I never worked with it, first time to mechendo tb.. :(
– Joana
I believe that what will demand in the case is the "payment", perhaps it was the case to use an exact search, no ?
– Motta
is that the search is coming from a variable that takes the value of a select for the post, because the user who selects the type he wants to search for... : $category = $_POST['comboB'];.. but the conflict is or the words are iguias.. I will research better here...
– Joana