mcmuney Posted August 10, 2006 Share Posted August 10, 2006 I'm using ORDER BY RAND() function, which works. The problem is that when results are > 10 and pagination is used, it randomizes the results on every page. I would like it to randomize once and when viewer goes to page 2, it should not randomize again. How can I achieve this? Thanks. Link to comment https://forums.phpfreaks.com/topic/17087-rand/ Share on other sites More sharing options...
hitman6003 Posted August 10, 2006 Share Posted August 10, 2006 There is no good way of doing that. The purpose of using RAND() is to get a different sort order each time.The only thing I can think of off hand would be to do your query, then store the result somewhere...in a session, or in a file, so that when the user goes to the next page you are able to retrieve the same result set and get the next 10 records for them to view. Link to comment https://forums.phpfreaks.com/topic/17087-rand/#findComment-72175 Share on other sites More sharing options...
king arthur Posted August 10, 2006 Share Posted August 10, 2006 Can you seed the random number that MySQL uses from some known point? If so you could just seed it from the same point twice, but I don't know enough about MySQL to know if you can. Link to comment https://forums.phpfreaks.com/topic/17087-rand/#findComment-72179 Share on other sites More sharing options...
hitman6003 Posted August 10, 2006 Share Posted August 10, 2006 According to the manual, you can:http://mysql.com/doc/refman/5.0/en/mathematical-functions.html#id3220613Which means that all he would have to do is get a random number, use it so seed mysql's RAND function, then store that number in a session to be used in all subsequent queries.Good suggestion. Link to comment https://forums.phpfreaks.com/topic/17087-rand/#findComment-72187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.