How to create a page that lists all users and profile fields

Ref: http://drupal.org/node/513240

<?php
// Compile a list of fields to show.
$fields = array();
$result = db_query('SELECT name, title, type, weight FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', PROFILE_PUBLIC_LISTINGS);

while ($record = db_fetch_object($result)) {
$fields[] = $record;
}

// v.fid = 1 is the include in member gallery checkbox
// If the field contains integer values use ORDER BY ABS(v.value) to force numeric sorting

//Change the 50 to display more or less users per page
$result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = 1 ORDER BY u.name, v.value ASC", 50, 0, NULL);

$output = '<div id="profile">';
while ($account = db_fetch_object($result)) {
$account = user_load(array('uid' => $account->uid));
$profile = _profile_update_user_fields($fields, $account);
$output .= theme('profile_listing', $account, $profile);
}
$output .= '</div>';
$output .= theme('pager', NULL, 20);

return $output;
?>

v.fid = 1

fid 為 profile_fields 中的主鍵

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
本篇發表於 PHP code。將永久鏈結加入書籤。

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *