Milan Parekh
Milan Parekh

Reputation: 163

search string from database and get near words php

i need suggestion for search word and get near by words.. lets take an example..

i have one product table

Samsung Galaxy Z8 (Midnight Black, 64 GB)  (4 GB R...
Samsung Galaxy On Max (Gold, 32 GB)  (4 GB RAM)
Samsung Galaxy J7 Prime (Gold, 32 GB)  (3 GB RAM)
Samsung Galaxy J3 Pro (Black, 16 GB)  (2 GB RAM)
Samsung Galaxy Note 5 (Dual Sim) (Silver Titanium,...
Apple IPhone 4 (Black, 8 GB)
Apple iPhone 4 (White, 16 GB)

which have mre products like samsung iphone etc. so i want to do search query like if user type "J3" than return samsung galaxy J3 pro..

lets take another search. if user type only "Z" than return "Samsung Galaxy Z8".. please help me.

Upvotes: 1

Views: 40

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269833

Is this what you want?

where name like concat('%', ?, '%')

The ? is the placeholder for the string parameter provided by the user.

Upvotes: 1

Related Questions