How to save search criteria or search results?

I have a php ad site (mostly), and I'm currently using MYSQL as a database. Later I will use SOLR or, possibly, Sphinx as a “search engine”.

I want users to be able to see the “results” of searches they did before, but I don’t know where to start ...

How it's done?

I currently have a form that fills out and when submitted php just checks the mysql table to see if there are any matches.

Do I have to store “search criteria” and perform a new search every time users click on one of their previous searches or do I need to save the results? I would prefer to do a new search because new items may have been inserted since the last search!

If you need more input, just let me know and I will update this Q.

thank

+3
source share
4 answers

Well ... if you're mostly talking about "saved searches," I'm doing something similar right now, so I just have a separate table where ....

saved_search_id (primary) | user_id (foreign) | search_name | criteria1 | criteria2 | criteria 3 ... etc.

, , , , . .

?

+2

($_GET) . . , , .

, , . MySql .

+1

: , - , .

0

Save your search criteria. This will take care quite a bit, as if the data has changed, users will get old results. And consider a space whose results may take some time :)

I would also consider saving search criteria, not the actual query. If you change the database, saved searches will still work the same way you need to update the query generation mechanism as well, but you most likely forgot to update each saved query.

0
source

Source: https://habr.com/ru/post/1727600/


All Articles