Best unofficial Apache Server developers community |
|
I want to select the most recent 12 rows from a table, but then shuffle the order. So i cant use ORDER BY RAND() becouse that would just randomly pick some rows and not the most recent 12 rows. I was thinking something like this, but it didnt work out as planned:
later when i do:
i excepted the key to be photo_id and the value to be photo_name with the correct relation between them, guess i was wrong. Any tips about how to solve this problem? Maybe my approach isnt good at all. Best of regards, Alexander
posted via StackOverflow
|
|
 
|
You could put them all in an array in PHP, then randomize the order of that array with |
|
 
|
You could use a subquery:
|
|
 
|
PHP's
This function is best used with numerically indexed arrays. A quick approach would be to just write your own shuffle function that works on associative arrays. I found this one on a previous Stack Overflow post:
Link to the original: |