I’m writing a ajax search function using PHP. It’s working correctly but have little problem with filtered results,
I have product description like below
POWER CORD C13-C14 SVT 250V 10AMP GREEN JACKET 8 FEET
but when user search for power cord green there is no result showing. i think this because of those above words are not in same order.
here is my SQL code – $qr is user search word
SELECT
product_name,product_desc
FROM j25_virtuemart_products,j25_virtuemart_products_en_gb
WHERE
j25_virtuemart_products.virtuemart_product_id =j25_virtuemart_products_en_gb.virtuemart_product_id
AND j25_virtuemart_products.published=1
AND (product_name LIKE '%$qr' OR product_desc LIKE '%$qr
when user search for power cord green i need to get POWER CORD C13-C14 SVT 250V 10AMP GREEN JACKET 8 FEET as a suggestion. can anyone tell me how to write query for get those kind of result. thank you
You have to use FULL TEXT searching. Before using it make sure to check your database engine if it support FULL Text. Also you have to index fields like title, description whatever you have to support full text.
YOu can refer to
Also note that:
mysqliorPDO