I have been researching this for a while and can't seem to find any good solutions so I thought I would see if anyone here has done this before that has a simple solution. Is there a way to update the query as someone is typing in the input box? The result is used on index.php where a while loop is ran on the result. I have tried a couple tutorials but I couldn't find anything that would just change the query.
<input name="search" type="text" id="search" autocomplete="off">
$search_string = preg_replace("/[^A-Za-z0-9]/", " ", $_POST['search']);
$search_string = $tutorial_db->real_escape_string($search_string);
$result = mysqli_query($con,"SELECT * FROM directory WHERE concat(fname,' ',lname) LIKE '%".$search_string."%'");