Advertisement
Faguss

Userspice get all users table example1

Jan 19th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement