php - How to SELECT LIKE from SQL without duplicate viewing id -
i using code :
<? $i_count=1; $ssql = "select * projects status=1 , location '%" . $a_project[0]["location"] . "%' order delivery_year desc, project_id desc limit 0,5"; $mysql_result = mysql_query($ssql, $globals['conn']); $num_rows = mysql_num_rows($mysql_result); if ($num_rows > 0) { ?> <br />
it show project same location viewing project. show current project in result. ex : have 02 projects in location hanoi name , b. when view project a, related projects show both , b project.
how can fix ? thanks
exclude current project in where:
select * projects status=1 , location '%" . $a_project[0]["location"] . "%' , id <> " . $a_project[0]["id"] . " order delivery_year desc, project_id desc limit 0,5
(or it, depending on field names , such)
Comments
Post a Comment