I need to pull a data set using PHP and order it randomly. Every time it is pulled, I need a different random order.
Once the data is pulled I’m using ajax/jquery to pull the results 12 at a time. So I have to keep working with the same result set, only pulling 12 records at a time based on the pagination.
Can anyone explain to me how to do this with mysqli/php, I think it would be using store_result and possibly data_seek. But I was hoping someone on here with some experience with this could point me in the right direction.
My current query …
SELECT * FROM mytable WHERE status='active' limit 0,12
I did it once using the MD5 function.
You generate a random seed (salt) with php and just append it to all your IDs for example :
(Replace :salt with ‘aE41n’ for example)
Then, all you have to do is storing the salt in a session for each user.
Don’t know if it’s the best solution considering performances, but I hope it will help.