This is my code:
$q = '8gb pro';
$sforeach = explode(' ', $q);
$treffer = "when (titel LIKE '% $q %') then 1";
$sortstring = "";
foreach($sforeach as $sf)
{
$sortstring .= "(titel LIKE '% $sf %') AND";
}
$sortstring = rtrim($sortstring, ' AND');
$sortstring2 = "";
foreach($sforeach as $sf)
{
$sortstring2 .= "(beschreibung LIKE '% $sf %') AND";
}
$sortstring2 = rtrim($sortstring2, ' AND');
$sort = "order by case
$treffer
when $sortstring then 2
when $sortstring2 then 3
else 4
end, views DESC";
When I search for let's say 8gb pro
then rows with title
like Acer TravelMate P648-MG-71S5
are displayed before rows with title like Dell Radeon Pro WX 7100 8GB GDDR5
even though the condidion when $sortstring then 2
should come before when $sortstring2 then 3
and place it the other way around right?