OH Pavel OH Pavel - 6 months ago 39
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


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

  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'"