0

Hi I am using the following query:

"SELECT * FROM members WHERE name LIKE '$searchKey%';"

Where $searchKey is a variable that contains the string to be searched. The problem is that the code only searches until it has found a space and even if characters after space match the value, it returns null.

Eg:
Database has two entries:
Andy Johnson
Paul Ford

1. $searchKey = "An" - The code works fine and returns 'Andy Johnson'
2. $searchKey = "For" - Returns Null; however I want it to return "Paul Ford"

Thanks

Edited by iammirko: Incomplete written

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by iammirko
0

put a % symbol BEFORE and AFTER the variable name:

"SELECT * FROM members WHERE name LIKE '%$searchKey%';"
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.