How to print "latest avatar" user list in a block in Drupal? Php code?

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


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.

                                     

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.