OH Pavel OH Pavel - 1 year ago 74
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 Source

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'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download