How to print "latest avatar" user list in a block in Drupal? Php code?
1. Go to Admin
2. Go to Blocks
3. Add Block
4. Add following code.
<?php
$sql = db_query("SELECT picture from {users} order by created DESC" );
$i = 0;
$cntr_limit = 3 ;
$row_cntr = 0;
$cntr_limit = 9;
$output .="<table><tr>";
while($pic = db_fetch_object($sql))
{
if ($pic->picture){
$picture = theme('imagecache','thumbnail', $pic->picture);
$output .= '<td><table height="100%"><tr><td height="100%" style="vertical-align: middle; width:50px; ">'.$picture .'</td></tr></table></td>';
$row_cntr++;
if ($row_cntr == 3 || $row_cntr == 6 || $row_cntr == 9) {
$output .= "</tr> <tr>";
}
$i++;
if ($i >= $cntr_limit) {
break;
}
}
}
$output .= '</tr></table>';
print $output;
?>
6. Enable block on right side or left side. You are done.
