Random Pagination

Hi Experts,

Is there way to do Random pagination?

I'm not with order, or sort basis. just random pagination

regards,

Bala

How about page = rand(max_number_of_pages)?

-- Long http://MeandmyCity.com/ - Find your way http://edgesoft.ca/blog/read/2 - No-Cookie Session Support plugin

Thanks for the reply Expert,

but my problem is very different approach to random pagination.

likewise, i've home page where i've to display some categories randomly with limit of 5 to 6 datas in a page,

if oracle doesnt support random function then how we solve this issues? without complications.

regards,

Bala

Thanks for the reply Expert,

but my problem is very different approach to random pagination.

likewise, i've home page where i've to display some categories randomly with limit of 5 to 6 datas in a page,

if oracle doesnt support random function then how we solve this issues? without complications.

I vaguely recall reading how wikipedia do their 'random article thing' - each article is assigned a number between 0 and 1 (randomly and
uniformly). - to pick a random article generate a random number p and pick the
first article whose assigned number is greater than p

Fred

Totally blocked :frowning:

Totally blocked :frowning:

Say what?

Fred

Really you should do the leg work yourself if you want it done. But here is the pseudo as you seem to need it.

1. count the total number of rows - SQL 2. calculate the max_number_of_pages - Ruby 3. page = rand(max_number_of_pages) - Ruby 4. calculate the offset - Ruby 5. select the rows using 'limit offset, items_per_page' - SQL

If that doesn't help, I'd have to agree with Frederick. 'Say what?'

-- Long

thank you guys, it works well,

    @categories = Category.find(:all, :conditions => ["parentid=0"], :limit => 5, :offset => rand(5))

remember rand(5) is hardcoded

thanks for all your suggestions and help

regards, Bala