php - Random values in MySql query with pagination -


i have advanced search on web page, how works follows. when search made, random results appear on content page, page included pagination, problem everytime visitor goes 1st page different results appear. possible use pagination this, or ordring random.

i'm using query

select * table order rand() limit 0,20; 

you should use seed mysql rand consistent results. in php

$paginationrandseed = $_get['paginationrandseed']?     ( (int) $_get['paginationrandseed'] ):     rand() ; 

and in mysql use seed

"select * table order rand(".$paginationrandseed.") limit 0,20" 

of course you'll need propagate initial seed in page requests.

good luck,
alin


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -