how best to implement a search filter in php Here's how it turned out
if(isset($_GET["name"])) { $name = htmlentities(stripslashes($_GET['name']), ENT_QUOTES, "UTF-8"); $t[] .= "(name LIKE '%$name%' OR text LIKE '%$name%')"; } if(isset($_GET["tags"])) { $tag = htmlentities(stripslashes($_GET['tags']), ENT_QUOTES, "UTF-8"); $t[] .= "(tags LIKE '%$tag%')"; } if($t) { $d = "WHERE"; $t = implode(" AND ", $t); } else { $d = ""; } $rezult = mysql_query("SELECT * FROM product $d $t"); And a simple form, everything basically works, I would like to know about the correctness of the code and maybe there is an easier way.
htmlentities(stripslashes(...does not help, ru.stackoverflow.com/q/511895/186083 - Vismanmysqliis a more modern and much safer extension for PHP. - Andrei