ok well i have this coding working $query = mysql_query("SELECT * FROM stock WHERE item_code LIKE '%$search%'"); but i dont want it to be LIKE i want it to be exact so i try $query = mysql_query("SELECT * FROM stock WHERE item_code = '%$search%'"); but it doesn't work, can anyone think why ???
When you do pattern matches you need to use LIKE or NOT LIKE. This is a built in feature of mysql that lets it know you need to match a pattern. http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html You either need to do: mysql_query("SELECT * FROM stock WHERE item_code LIKE '%$search%'"); or mysql_query("SELECT * FROM stock WHERE item_code = '$search'");
he says he wants to be exact then the code is $query = mysql_query("SELECT * FROM stock WHERE item_code='$search'"); also please do not use * in searching use index for faster result.
Try this method $query = mysql_query("SELECT * FROM stock WHERE item_code = '%".$search."%'"); Code (markup): edit: sorry i didnt read your question carefuly, please disregard this post