OH Pavel OH Pavel - 2 months ago 9
PHP Question

mysql query not showing result

can anyone help me to solve this mysql query problem

$rela=mysql_query("SELECT *
FROM pvl_posts
WHERE (title LIKE '%$title%' OR post LIKE '%$title%'')
OR (title LIKE '%$post%' OR post LIKE '%$post%'')
AND id != '$id'");


I want use it as related articles

Answer

You have some wrong quotes and use concat for the like string

"SELECT * 
  FROM  pvl_posts 
  WHERE (title LIKE concat('%', '$title','%') OR post LIKE concat('%','$title' ,'%') )
  OR (title LIKE concat('%' , '$post', '%')   OR post LIKE concat('%','$post','%') )
  AND id != '$id'"