I needed to make a block in drupal that contain my recent posts and so, I write this code snippet.
<?php
// Get all node IDs and it title from the "node" table
// Customize the types retrieved from the "type" field
// (Status=0 & Moderate=0) mean the post is published
$result = mysql_query("SELECT nid, title
FROM node
WHERE (type='story' or type='blog'
OR type='flexinode-1')
AND NOT (status=0 and moderate=0)
ORDER BY nid DESC")
or die(mysql_error());
echo
"<ul>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print node titles linked to its page into unsorted list
echo "<li>";
echo "<a href=\"http://ikhnaton2.com/
node/{$row['nid']}\">$row['title']}</a>";
echo "</li>";
}
echo "</ul>";
?>
Enjoy :)
Another trick: Display a list of node titles from a specific category
Recent comments
21 hours 49 min ago
1 day 5 hours ago
2 days 12 hours ago
4 days 8 hours ago
1 week 8 hours ago
1 week 3 days ago
2 weeks 3 hours ago
2 weeks 7 hours ago
3 weeks 1 day ago
3 weeks 4 days ago