Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building an Online Food Ordering System with PHP and MYSQL, One of the feature of the application is to allow users to search for the restaurants by typing the area name. I would like to know using PHP for search will be more efficient or using Stored Procedure or using any third party tool.

Efficient in the sense when it is to be searched among large set of data which one will be the fastest?

share|improve this question

Most likely this should be done with SQL. This would be simpler and have better performance.

But would depend on a few details. Especially how exact or complicated you want it to be able to find the information the user typed in (maybe a list of available areas would be a better ui option here)

You could do a simple search like:

SELECT * FROM areas WHERE name LIKE 'input%';

This would of course fail for any typo the user makes and maybe return several records and you would have to offer the user further options to select one of those.

Assuming at some point you found a single record, it should be simple to find restaurants by area_id.

share|improve this answer
About the list of available areas, I will be implementing autocomplete feature. Using SQl like in the query will not be help full, I tried Full Text Search but the problem is with the typo, for example if user types "GS ROAD" it is found in the database,but if it is typed as "GSROAD" it is not found. – user92961 Jun 4 '13 at 8:30
If you want correction on that level a full text search engine like Solr or Sphinx would do a better job. But do you have that many locations that they won't find into a simple selection? Especially with names of places you will always have problems to sort out the right spelling. (You could split the string at spaces and search for those, or remove spaces, so you could prepare a list of possible words with PHP and search for each, but you may get arbitrary results that way) – thorsten müller Jun 4 '13 at 8:42

You may need to redesign how client provide "area" information. The geography information is naturally in hierarchy. So you'd better provide a multi-steps input process. All restaurants are stored with state,city,town or street information, client will be provided with drop-down list, first select a state, then select a city, then a town or street, then you fetch the corresponding restaurants and display them on the page.

Or, leverage map service provider's API, first convert their INPUT into coordinates. And you have coordinates information associated with each restaurant.

share|improve this answer
It is just for one city – user92961 Jun 4 '13 at 8:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.