Im trying to return 10 recent blog posts with the users avatar who made the post. Can someone fluent in php help me with this.

<?php
  $uid = arg(1);
  $nlimit = 5;

  $result = db_query("SELECT n.created, n.title, n.nid, n.changed
  FROM node n
  WHERE n.status = 1 and n.type='blog'
  ORDER BY n.changed
  DESC LIMIT $nlimit");
  $output3 .= $node->name;
  $output3 .= node_title_list($result);
  print $output3;
  ?>

This code returns a bulleted list of recent blog titles. I dont want bullets, but just a users avatar and next to it the blog title.

Comments

stevenpatz’s picture

$sql = "SELECT DISTINCT(n.uid), u.picture,u.name,n.nid, n.title FROM {node} n JOIN {users} u USING(uid) WHERE type = 'blog' ORDER BY n.changed DESC LIMIT 10";
$results = db_query($sql);
$items = array();
while ( $anode = db_fetch_object($results) ) {
$items[]= "<img src='$anode->picture'>" . l($anode->title, "node/$anode->nid");
}

if ( count($items) ) {
 print "<div class='itemlist'>";
 print theme('item_list',$items);
 
  print "</div>";




}
j0k3z’s picture

That is almost perfect.

Is it possible to print it without the bullet list? I just want the image and then the node title next to it.

Thanks for the great help

stevenpatz’s picture

In your style.css file place this:

.itemlist {

list-style-type: none;
}
j0k3z’s picture

That is almost perfect.

Is it possible to print it without the bullet list? I just want the image and then the node title next to it.

Thanks for the great help

j0k3z’s picture

That is almost perfect.

Is it possible to print it without the bullet list? I just want the image and then the node title next to it.

Thanks for the great help

omnyx’s picture

quick question: do i just create a new page, set input to php, and put this code in??
cause if i do that, i just get a blank page upon submitting my page...any hints?
thanks

seth.young23’s picture

Is it possible to use an Imagecache Preset to resize the pictures?