daily pastebin goal
59%
SHARE
TWEET

Userspice get all users table example1

Faguss Jan 19th, 2018 (edited) 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. //We are asking the database for a list of all the users and give ALL the results
  4. $users = $db->findAll("users")->results();
  5. ?>
  6. <table class="table table-striped">
  7.     <thead>
  8.         <tr>
  9.             <th>Username</th><th>Joined On</th><th>Group(s)</th>
  10.         </tr>
  11.     </thead>
  12.     <tbody>
  13.         <?php
  14.         //loop through all the users and make one row for each user
  15.         foreach($users as $u){ ?>
  16.             <tr>
  17.                 <td><?=$u->username;?></td>
  18.                 <td><?=$u->join_date?></td>
  19.                 <td>
  20.                 <?php
  21.                     //Look through the permissions for this user
  22.                     $perms = $db->get("user_permission_matches",["user_id","=",$u->id])->results();
  23.                    
  24.                     foreach($perms as $p)
  25.                         echo $db->cell("permissions.name",$p->permission_id) . ",";
  26.                    
  27.                  ?>
  28.  
  29.                 </td>
  30.             </tr>
  31.         <?php } ?>
  32.     </tbody>
  33. </table>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top