Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
AD Gallery 11
SyntaxHighlighte... 41
Newsletters v4.03 102
Facebook Like Box 114
Newsletters v4.02 55
Metro 143
Facebook Connect 161
Shoutbox Panel 122
Redactor for PHP... 102
MI Floating Side... 105
Facebook Login/R... 146
Avatar Studio v2.03 174
Relationship Sta... 92
Sexual Orientati... 111
Fisherman 138
Popular Addons
iTheme2 5789
Arise 5778
User Control v1.23 4608
Event Calendar 4036
Photowidget panel 3878
Radio-Theme red2... 3342
Highslide Gallery 3306
CSS/JavaScript D... 3218
Facebook Connect... 2972
Dynamic Menu 2885
Slideshow Lightb... 2712
L-AMANT 2654
Enigma 2627
2Dark 2601
Black 2565
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Code Snippet and functions
Who is here? 1 guest(s)
 Print Thread
Members Listing
afoster
What code would I use to pull the members name, email address from the users table and the user group associated with the member name from the user_groups table?

I believe it involves a JOIN which is where I get lost.
 
smokeman
With a little modification to the file /members.php you get what you are asking for:
Download source  Code
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: members.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."members.php";

add_to_title($locale['global_200'].$locale['400']);

opentable($locale['400']);
if (iMEMBER) {
   if (!isset($_GET['sortby']) || !ctype_alnum($_GET['sortby'])) { $_GET['sortby'] = "all"; }
   $orderby = ($_GET['sortby'] == "all" ? "" : " AND user_name LIKE '".stripinput($_GET['sortby'])."%'");
   $result = dbquery("SELECT user_id FROM ".DB_USERS." WHERE user_status='0'".$orderby);
   $rows = dbrows($result);
   if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
   if ($rows) {
      $i = 0;
      echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n";
      echo "<td class='tbl2'><strong>".$locale['401']."</strong></td>\n";
      echo "<td class='tbl2'><strong>".$locale['405']."</strong></td>\n";
      echo "<td align='center' width='1%' class='tbl2' style='white-space:nowrap'><strong>".$locale['402']."</strong></td>\n";
      echo "</tr>\n";
      $result = dbquery("SELECT user_id, user_name, user_status, user_level, user_groups, user_email FROM ".DB_USERS." WHERE user_status='0'".$orderby." ORDER BY user_level DESC, user_name LIMIT ".$_GET['rowstart'].",20");
      while ($data = dbarray($result)) {
         $cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"); $i++;
         echo "<tr>\n<td class='$cell_color'>\n".profile_link($data['user_id'], $data['user_name'], $data['user_status'])."</td>\n";
         $groups = "";
         $user_groups = explode(".", $data['user_groups']);
         $j = 0;
         foreach ($user_groups as $key => $value) {
            if ($value) {
               $groups .= "<a href='profile.php?group_id=".$value."'>".getgroupname($value)."</a>".($j < count($user_groups)-1 ? ", " : "");
            }
            $j++;
         }
         echo "<td class='$cell_color'>\n".($groups ? $groups : ($data['user_level'] == 103 ? $locale['407'] : $locale['406']))."</td>\n";
         echo "<td align='center' width='1%' class='$cell_color' style='white-space:nowrap'>".$data['user_email']."</td>\n</tr>";
      }
      echo "</table>\n";
   } else {
      echo "<div style='text-align:center'><br />\n".$locale['403'].$_GET['sortby']."<br /><br />\n</div>\n";
   }
   $search = array(
      "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
      "S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
   );
   echo "<hr />\n<table cellpadding='0' cellspacing='1' class='tbl-border center'>\n<tr>\n";
   echo "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."?sortby=all'>".$locale['404']."</a></td>";
   for ($i = 0; $i < 36 != ""; $i++) {
      echo "<td align='center' class='tbl1'><div class='small'><a href='".FUSION_SELF."?sortby=".$search[$i]."'>".$search[$i]."</a></div></td>";
      echo ($i == 17 ? "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."?sortby=all'>".$locale['404']."</a></td>\n</tr>\n<tr>\n" : "\n");
   }
   echo "</tr>\n</table>\n";
} else {
   redirect("index.php");
}
closetable();
if ($rows > 20) { echo "<div align='center' style='margin-top:5px;'>".makepagenav($_GET['rowstart'], 20, $rows, 3, FUSION_SELF."?sortby=".$_GET['sortby']."&amp;")."</div>\n"; }

require_once THEMES."templates/footer.php";
?>



 
http://www.phpfusion-tips.dk/
afoster
Thank you smokeman, I will do a compare between the two files to see where the "little modification" took place.
 
smokeman
Line 38 added: , user_email

Line 52: Changed ".getuserlevel($data['user_level'])." to ".$data['user_email']."
 
http://www.phpfusion-tips.dk/
afoster
Thanks again smokeman, saved me some time and taught me some more code.

Merged on Mar 22 2012 at 12:27:20:
How can I adapt the code noted above to list users by user group? Is it even possible as I have quite a few user groups and would benefit by being able to list the members associated with the different user groups.
Edited by afoster on 22-03-2012 20:27
 
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
Batch deleting spam unactivated members? User Administration 12 07-03-2013 09:23
Unactivated members & Email Notification User Administration 8 01-03-2013 10:20
Help keep the display there is a link submit profiles of members Panels and Infusions 1 07-02-2013 08:14
looking for an infusion or panel with members not on hold in order to be approved Panels and Infusions 4 06-02-2013 21:05
Newest Members Panel Official releases [Panels] 3 04-01-2013 15:09
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue