I have this table with song titles, artist etc.
| id | artist | title | search_tags |
if(isset($_POST["search_value"]) && $_POST["search_value"] != null) {
$search_value = $db->mysqli->real_escape_string($_POST["search_value"]);
//hiq apostrofet
//hiq pikat
$search = array("\'", ".", " ");
$replace = array("", "", " +");
$search_value = str_replace($search, $replace, $search_value);
$query = "
select * from `music`
where
match(`search_tags`) against ('+$search_value*' IN BOOLEAN MODE)
order by views desc
limit 1
";
//+ vihet per t paren
$run_query = $db->mysqli->query($query);
$result = $run_query->fetch_assoc();
if($run_query->num_rows > 0)
echo json_encode($result);
}
It works fine in most cases but it is not working for some others.
Two main problems are:
- If I have two songs with these search tags:
a) era isterfi money per money
b) era istrefi e dehun
and when I search using this query: era e dehun
it shows me era istrefi money per money
as a result. Why is this happening? Are single chars a problem?
And 2.
If I have a song with search_tags: 23 miley cyrus
and I use 23
as a search query it shows me no result. Everything work fine if I search Miley for ex.