I am trying to retrieve data from a table based on if the user enters characters in a search bar which match with a variable that holds the description of an item.
I am doing this using MySQL in PHP and this is the retrieval code I have so far:
$ItemDesc = $_POST['ItemDesc'];
$query = "select * from StockItems where ItemDesc LIKE '%$ItemDesc%'";
However I am not getting back the right result, what I am getting back is all the data in the SQL table despite entering unmatching characters all the time.
So e.g. if in the SQL tabel I have one field and the ItemDesc row contains 'Fight', if i enter 'xxx' into the search box and click enter the field will always be retrieved.