Drupal 6: getting random data from database
I spend few开发者_StackOverflow中文版 hours at google, but cant find :/
is it possible to get a random data from database with Drupal 6?
appreciate helps!! thanks!
If you want random data, there is no point in getting it from the database, you should generate it PHP instead.
To answer your question: If you want to get a random row from your db you can do: (MySQL only)
SELECT * FROM table
ORDER BY RAND()
LIMIT 1
But you still have to specify the table.
Why not use Views? You can set what content to pull, limit to 1 result, and tell it to sort it randomly.
do you want to get random nodes? Random Users? Random comments? The question is a little vague. Views can support a random ordering and random filtering. . . so you can get back your content in either a random order or a random selection. Does that help?
精彩评论