Список документов определённого типа за определённое время



Этот код выведет список всех документов типа book созданных с 1 июня 2007 года по 1 июля 2007 года, упорядочив их по дате создания.

<?php
$node_type
= "book";
$start_stamp = 'June 1 2007';
$end_stamp  = 'July 1 2007';
$start_stamp = strtotime($start_stamp);
$end_stamp = strtotime($end_stamp);
$sql = "SELECT node.title, node.nid FROM node WHERE node.created < $end_stamp AND node.created > $start_stamp AND node.type = '$node_type'" ;
$output .= "<ul>";
$result = db_query($sql);
while (
$anode = db_fetch_object($result)) {
$output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output .= "</ul>";
print
$output;
?>

Comments

Поправьте:

SELECT title, nid

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.