random article
|
19 posts
|
Hi all ,
but cannot understand the use of the object for the DB query . anyone can help ? |
|
19 posts
|
up :) I thought that i can do this by simply play with array but i think is bettere to do this via database instructions. so i’m here to know :P |
|
316 posts
|
Why not use a combination of the find routine and a random number generator to choose “randomly” a mysql row? |
|
1493 posts
|
OK. Thought I’d try to contribute something useful for a change! :) Here’s what I did: first, googled! And found an article on randomizing an array in PHP. That gave me the basis for the following:
Done! You can see the results if you like. The Random Article code above doesn’t include comments, but you could include that if you like. Or readers can click the “Permanent link” to get the full picture. There are probably other more elegant, more random ways of doing this. But for “quick-and-dirty”, I hope that’s a help. (Plus: more info on |
|
19 posts
|
mhm the David answer is interesting and very near what i’de like to know. But the question is/was how to use : children(array(‘limit’ => 6, ‘offset’ => 0, ‘rand’ => ‘position ASC’)) with the MySQL RAND function |
|
1493 posts
|
Sorry, Matteo. I thought the question was how to “select random an article from DB” — someone else will have to help you with the more specific question! :) |