Reputation: 1464
i need some help to search property searching like on
what i am unaware of is that how would i send the query to the next page? eg my query is like this
$query = select * from xyz where city='a' and location='b' and price between 'c' and 'd' and area between 'e' and 'f' and bedrooms='g' and addedwithin 'h';
considering this query on the basis of form on the above mentioned website, what should be the scenario for searching property listings.
Also how should i get this query again when i use paging with this page. should it be like this
<a href="<?php echo $_SERVER['PHP_SELF'] . '?q=' . $query; ?>" > nextpage </a>
or is there any other simpler solution?
Thanks
Upvotes: 1
Views: 246
Reputation: 10517
you may store user search phrase e.g. in session coockies or keep in form parameters (e.g. with hidden type). then do db-request again with new offset
Upvotes: 0
Reputation: 15961
You could do a few things. One solution would be to pass all the parameters you need in the query string along with a page number, and then do paging in your SQL. This might be fine for smaller things but issues might arise if something was inserted into your table after the search, so the search results can increase/decrease and seem odd to the user. There is also a problem if a spider started crawling your site by increasing the page parameter - it would be very easy to overload your database.
Another solution, which would be my favourite, would be to save all your results from the initial search into a cache solution using some unique ID as the key. Then your paging can be passed the ID of cache item and page number and you can read off from the array of results the page that you want.
Upvotes: 2