Query and print out random nodes in drupal How to query random nodes in Drupal 6 without views?

I can print out last nodes but random nodes are the problem.
Not sure where you are doing this, but this would be one dull ax way of doing it:

$query=db_query('SELECT nid, RAND() as _random FROM {node} WHERE status = 1 ORDER BY _random ASC LIMIT 1');
$result=db_fetch_object($query);


and then you can do whatever you want with $result-&gt;nid, another dull ax:

drupal_goto('node/' . $result-&gt;nid);


or

$node=node_load($result-&gt;nid);
// do whatever you want with it


etc