简体   繁体   中英

mysql search queries and pagination with php or javascript

Im developing a site where its users can search for other users on the same website.

The queries can be very long and complex, so i would like to save some of the work done, so i dont have to repeat the same work again.

I was thinking i could save the results in a table, so when i use pagination it woudnt have to do the same query all over again, it could just get the results from the result table. How does this sound?

Maybe there is another better way? Is it possible to save queries in php sessions? Is this a good idea? Also im not sure what kind of pagination i should make, the one that goes like , prev , 1 , 2, 3 ,4 , next, or the "facebook style" where u just add 20 more results to the page every time scroller hits 10% of bottom window.

Any thoughts on the matter? :))

Best of regards, Alexander

Would all users be submitting similar queries? If so, you may want to look into caching, such as memcached .

As for the pagination, if you want users to see the next X results automatically, somewhat like what's described here .

Just optimize your search query (if needed).
In fact, database intended to "to repeat the same work again". Nothing wrong with it.

No need to output results to a table. If you're really concerned, index and even do stored procedures, but it's likely not necessary.

I like building an Ajax query with DataTables , then using their Pipeline feature to grab a few sets of results ahead of and behind the data that the user has actually requested--based on filter, pagination, and sorting variables that are pre built-in to the front-end code. Because you're spreading out the queries, it appears to the user that it's not taking any time at all to do. I have it running on tables of several hundred thousand results very effectively. And, it's VERY easy to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM