Skip to main content
September 12, 2008
Question

random results and paging

  • September 12, 2008
  • 1 reply
  • 263 views
Hi guys, I have query which returns random X numbers like:

SELECT field FROM table
ORDER BY NewId()

Now I want to display results in sequence by 2 using "<cfoutput startRow maxRows..>"

problem is when I display first two records and hit next page refresh and I get different query result set (they get randomized again so I am getting a lot of repeated records)

Any idea how to solve this, only thing that is coming to my mind is to cache query in session but... there must be better way.

Thanks
This topic has been closed for replies.

1 reply

Inspiring
September 12, 2008
What's wrong with making it a session variable? If you are displaying x records per page, you'd have to do something like that anyway.
September 12, 2008
Hi, actually I am displaying always 2 records per page,
storing query result in session is a bit of a problem (CF setting is that session is active for 12 hours), and requirement is: every site entry to show two different items on page with next prev links to scroll two by two.
Everything is working just fine, only this next prev links are giving me problems since query refresh and return different set of records (since it is random) so there are duplicates.

Thanks