Drupal: Display a block of random members with picture and basic info
Submitted by chris on June 12, 2006 - 02:45. Drupal Snippets<?php
$fields = array();
$result2 = db_query('SELECT name, title, type, visibility, weight FROM {profile_fields}
WHERE name IN ("profile_full_name", "profile_country") ORDER BY weight');
while ($record = db_fetch_object($result2)) { $fields[] = $record; }
$count = 2;
$Block_h = $count * 85;
$result = db_query_range(db_rewrite_sql("SELECT * FROM {users} u Where
CHAR_LENGTH(picture) > 0 ORDER BY RAND()"), 0, $count);
while ($user_info = db_fetch_object($result)) {
$user_info = user_load(array('uid' => $user_info->uid));
$profile = _profile_update_user_fields($fields, $user_info);
// $output .= theme('profile_block', $user_info, $profile, true);
// $output .= theme('profile_listing', $user_info, $profile);
$output .= "<div class=\"profile\" style=\"height: 85px\">\n";
$output .= theme('user_picture', $user_info);
$output .= ' <div class="name">'. theme('username', $user_info) ."</div>\n";
foreach ($profile as $field) {
if ($field->value) {
$output .= " <div class=\"field\">$field->value</div>\n";
}
}
$output .= "</div>\n";
}
print("$output");
?>

