Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

Problem with random results and pagination

Discussion in 'Programming' started by virtuoso, Mar 27, 2009.

  1. virtuoso

    virtuoso New Member Webmaster

    I have a search engine pulling the results from a MYSQL database with pagination.

    THE PROBLEM: I need the results to come up random on all the pages after each search or whenever the page is refreshed without doubling. I can do it with one page but the problem is with more pages.

    I'll be very grateful if somebody can come up with any ideas as I cannot find a solution anywhere.
  2. maneetpuri

    maneetpuri New Member Webmaster

    You can do this by.......


    You can do this by storing the ID of results fetched in a session and on the next page in the query exclude these, repeat this when ever the user moves to the next page. But this is not a good approach if the database is huge as it will increase the script execution time as the user will move to the next page.

    The other way is for every user create a temp table on the fly sort all the records in it, show the first set and then delete it so that when the user moves to the next page in the temp table the records already shown on the previous page are not there. Again script execution and server resources will be become a problem if the number of users accessing the site at one point of time are more and if the database is huge.


  3. overscan

    overscan New Member Webmaster

    What about storing the whole of the randomised search result in a session and just paginating through that?

Featured Resources (View All)

Share This Page