Insert the most recent poll
PLEASE NOTE! The PHP snippets are user submitted. Use at your own risk! For users who have setup Drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.
<?php
/**
* the following displays the most recent poll
* and assumes you have the poll.module enabled
*
* Works with Drupal 4.6
* Does not work with Drupal 4.5.x
*
*/
$sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1 AND n.moderate = 0");
$timestamp = db_result(db_query($sql));
if ($timestamp) {
$poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'moderate' => 0, 'status' => 1));
if ($poll->nid) {
// poll_view() dumps the output into $poll->body.
poll_view($poll, 1, 0, 1);
}
}
print $poll->body;
?>