I’m trying to write search function, that gets its parameter from the user and uses an SQL statement to get the result from a MySQL database.
The statement:
$title = $_GET['title'];
$result = mysql_query("SELECT name, phone, email from person where name= '$title'");
The problem with this statement is that it’s only taking the exact name; if the user is looking for “David” and just types “Da” then no result will be found.
I need a statement that, when the user enters part of the name, displays all matches with “Da”.
You can try a wildcard search, which is not optimal, but should work: