Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1.     class User
  2.     {
  3.         public $db;
  4.         public $id;
  5.         public $username;
  6.         public $password;
  7.        
  8.         public function __construct($db, $id = 0)
  9.         {
  10.             $this->db = $db;
  11.             $this->id = $id;
  12.         }
  13.        
  14.         public function showOne()
  15.         {
  16.             if($this->$id !== 0)
  17.             {
  18.                 $query = mysql_query("SELECT `username`, `password` FROM `user` WHERE `id` = $this->id");
  19.                 $result = mysql_fetch_assoc($query);
  20.                
  21.                     if($result)
  22.                     {
  23.                        
  24.                         $this->username = $result['username'];
  25.                         $this->password = $result['password'];
  26.                     }
  27.            
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement