Ranking results from the database as compared to user input

Sory for the long question but I just want you to get the concept. I will appreciate your help.

Am using laravel 5.2 to develop a website. I have 2 table (Menu and Hotels) which have columns (Menu => Food & Price) & for Hotels (HotelName …` Services’.) I have a form where the user enters what he/she wants in a hotel. e.g. doughnut, $10 (should be queried from table mene). The user may also put other services such as Available parking, wi-fi, currency exchange etc which should be selected from table Hotels column services. The results should be ranked and the output should be the name of the Hotels. The hotels should be ranked according to how they match user’s input. i.e. the hotel that have exact match will be ranked first, the nearest match will be second and so on. The services to be selected by the user are in form of checkbox, so the user selects what he/she wants. I then store them in one row inform of json.
The challenge am facing is to combine the two queries i.e. from menu table and Hotel table, and then rank the results. Guys, I will highly appreciate your help on how I can do this queries.

Have a read of INNER JOIN with regard to SQL queries, if the issue is combining the two tables. My problem would be how you order them by how close to your users selection they are.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.