V
V
Vertex2010-09-28 14:13:01
PHP
Vertex, 2010-09-28 14:13:01

Return to search results. (PHP)?

I don’t want to reinvent the wheel, but I can’t really find a solution on the net. Therefore, until I started writing my own, I would like to ask the habran population.
There is a database of, say, cars. For a search query consisting of approximately 4-5 fields, we display a list of results , then go to page 4 in the search results. As a result, we get something like this in the URL:
www.autosite.com/catalog/?page=4¶m1=21¶m2=...
On this page, we find what we need and go to view this object:
www.autosite.com/ view/id10001/
On the page for viewing this object, you must, for example, send an application through the form to this object. Those. reload the page again.
Hence the question:
How to implement a more correct return to the search results, i.e. dragging behind you constantly in the URL string:
?page=4¶m1=21¶m2=33¶m3=13&...¶m44=123
Moreover, search parameters can constantly change, be added or removed, and composing and dragging these parameters around is somehow not very convenient. So far, the only option I see is writing a layer that will process any incoming URL request and constantly pass it on. Although somehow it is not very beautiful ...

Answer the question

In order to leave comments, you need to log in

12 answer(s)
E
Eugene, 2010-09-28
@Nc_Soft

cookies ||
session ||
output_add_rewrite_var()

A
Alexander, 2010-09-28
@zlobin

But what if you write search parameters in cookies? and then process them

A
Alexey, 2010-09-28
@alexxxst

Sessions, cookies?

L
LIAL, 2010-09-28
@LIAL

>Unsubscribed above that this is not suitable, since within one session there may be N-number of search results
Sessions IMHO the best option. and than prevents to store in session an array (hash) with results of search?? or if they don't need to keep the variable somewhat and just overwrite it with each change in the search query???

S
shsmad, 2010-09-28
@shsmad

1. take "?page=4¶m1=21¶m2=33¶m3=13&...¶m44=123"
2. pass through base64
3. push it as a hidden field into the page
4. …
5. Profit!

O
Oleg Matrozov, 2010-09-28
@Mear

The only thing that came to mind in terms of separating the tabs of one browser is SessionStorage. But this is already JS and do-it-yourself. And it doesn't work everywhere.

R
Radik_Wind, 2010-09-28
@Radik_Wind

And what if all this is kept in a hidden field of the order form? And take the value from Referer?

D
Desiderata, 2010-09-28
@Desiderata

you can use AJAX and pass parameters via POST

K
Kir ---, 2010-09-28
@SowingSadness

Your use case describes a situation where it is best to use AJAX to submit a request, and return to the search via js:window.history

V
Vertex, 2010-09-28
@Vertex

Variants with AJAX disappear immediately because it is not kosher, since work with mobile browsers is also required, and not everyone supports them;
The option with various requests in the session is the most interesting, and I thought about it, but still, with some paranoia, I decided that this is no longer possible, since there may be supposedly 20-30 search windows open and then we will fly out of the session limits (if not a simple site), but I wanted some universality ...
Thanks for the answers, but so far I have not seen a single acceptable solution.
I do not believe that no one thought about some kind of layer.

V
Vladimir Chernyshev, 2010-09-28
@VolCh

The search handler generates a result set of records, saves them (in whole or only id) in the session with the key (you can also save query parameters there, for example, md5 from the search string and redirect to something like /search?key=hash - according to history, you can walk for a while and the load on the database is less

C
Cheese, 2010-09-28
@Cheese

that is your form is processed by the same page? Or is there an appeal to another and then redirection back?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question