If I'm doing a recipe site with a MySQL DB is preg_match the way to go? The table will be setup with recipe_id, recipe_name, recipe_description, and recipe_location. Every search I run on a search box only yields people talking about using a Google API.
Many thanks,
Joe
Search box with preg_match
Moderator: General Moderators
Re: Search box with preg_match
PHP's preg_match() does not really seem like an option to me. You would have to fetch all the records first, then loop through them all and use preg_match() to determine a match or not. An inefficient process.
Instead you can do the regex at the SQL level. MySQL has a REGEXP filter.
Instead you can do the regex at the SQL level. MySQL has a REGEXP filter.
Re: Search box with preg_match
Thank you so much. I needed an investigative lead. Efficiency is my goal but as a noob some ideas just seem unattainable.