I have made a search function for finding staff members based on a first name search, here is the code for that.
search.php
<?php
include ('connect-db.php');
if (isset($_GET ['forename'])){
$forename = $_GET['forename'];
$forename_escaped = mysqli_real_escape_string ($db, $forename);
$userquery = mysqli_query($db, "SELECT * FROM staff WHERE forename = '$forename_escaped'");
if (mysqli_num_rows($userquery) == null ) echo ('NO RESULTS FOUND IN DATABASE');{
?>
But what I would like this function to do is to return results even when in the search box the first name was misspelt by a letter or only partially entered.
e.g. User input - Search: Jennif -->[SEARCH FUNCTION] Returns results for 'Jennifer' OR User input - Search: Jjennifer --> [SEARCH FUNCTION] Returns results for 'Jennifer'
How could I perform an operation like this? I was thinking of using a 'LIKE' function but so far haven't been able to figure it out.