Advertisement
Guest User

Sahar Far

a guest
Sep 15th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.    
  3.     require_once 'config.php';
  4.  
  5.     // Select all users from the database
  6.     $selectUsers = $db->prepare('
  7.                                 SELECT * FROM users
  8.     ');
  9.  
  10.     $selectUsers->execute();
  11.  
  12.     $items = $selectUsers->rowCount() ? $selectUsers : [];
  13.    
  14. ?>
  15. <!DOCTYPE html>
  16.     <html lang="en">
  17.     <head>
  18.         <meta charset="UTF-8">
  19.         <title>Document</title>
  20.     </head>
  21.     <body>
  22.         <?php if (!empty($items)): ?>
  23.             <h3>Users:</h3>
  24.             <ul>
  25.                 <?php foreach ($items as $item): ?>
  26.                     <?='<li><a href="profile.php?token=', $item['token'] ,'">', $item['first_name'] ,' ', $item['last_name'] ,'</a></li>'?>
  27.                 <?php endforeach; ?>
  28.             </ul>
  29.         <?php else: ?>
  30.             <p>Sorry, there are no registered users!</p>
  31.         <?php endif; ?>
  32.     </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement