views:

196

answers:

3

Hi friends,

I spend few hours at google, but cant find :/

is it possible to get a random data from database with Drupal 6?

appreciate helps!! thanks!

A: 

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.

googletorp
A: 

Why not use Views? You can set what content to pull, limit to 1 result, and tell it to sort it randomly.

Kevin
A: 

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?

mirzu