I am trying to develop a way to search by having the user possibly enter one letter, and having the query return all matches with that letter. If the user enters two letters, then the results would show the matches with exactly the first two letters entered (regardless of case).
I have been experimenting with something like this to no avail:
$sql = "
SELECT *
FROM customer
WHERE cust_name like '%$name%'
ORDER BY cust_name asc
";
I would like the query to search, and return results exactly as the user enters the first few letters of the customer name. Right now, the query will return all customers with the letter 'a', if just 'a' is entered, instead of all customers beginning with the letter 'a' or 'A'.
TIA
I have been experimenting with something like this to no avail:
$sql = "
SELECT *
FROM customer
WHERE cust_name like '%$name%'
ORDER BY cust_name asc
";
I would like the query to search, and return results exactly as the user enters the first few letters of the customer name. Right now, the query will return all customers with the letter 'a', if just 'a' is entered, instead of all customers beginning with the letter 'a' or 'A'.
TIA