Using object oriented PHP to display users in a database I'm new to object oriented PHP, so I'm sure of the good or bad practices. The below code is working perfectly, I just don't know if it is a bad or good approach to use most of the methods as static and declare class properties as public.

Could someone provide me some advise?

In users.php

&lt;?php

class Users{

  public $user_id, $user_name, $user_email, $user_fname, $user_lname, $user_role;

  public static function display_users(){
      $display_users[] = self::find_all_query("SELECT * FROM users");
      return (!empty($display_users)) ? array_shift($display_users) : false;
  }

  public static function find_all_query($sql){
    global $database;
    $result = $database-&gt;query($sql);
    $db_result = array();
    while($row = mysqli_fetch_assoc($result)){
      $db_result[] = self::instantiation($row);
    }

    return $db_result;

  }

  public static function instantiation($row){

    $the_users_object = new Users();

    foreach ($row as $attribute =&gt; $data) {
      if($the_users_object-&gt;has_the_attribute($attribute)){
        $the_users_object-&gt;$attribute = $data;
      }
    }
    return $the_users_object;
  }

  private function has_the_attribute($attribute){
     $users_properties = get_object_vars($this);
     return array_key_exists($attribute , $users_properties);
  }


}
?&gt;


In admin-users.php

&lt;?php
$display_users = Users::display_users();

foreach ($display_users as $users) {
  echo "&lt;tr&gt;";
    echo "&lt;td&gt; $users-&gt;user_id    &lt;/td&gt;";
    echo "&lt;td&gt; $users-&gt;user_name   &lt;/td&gt;";
    echo "&lt;td&gt; $users-&gt;user_email &lt;/td&gt;";
    echo "&lt;td&gt; $users-&gt;user_fname &lt;/td&gt;";
    echo "&lt;td&gt; $users-&gt;user_lname &lt;/td&gt;";
    echo "&lt;td&gt; $users-&gt;user_role &lt;/td&gt;";
  echo "&lt;/tr&gt;";
}
?&gt;


In database.php 

&lt;?php
// require_once("init.php");

class Database{

  private $connection;

      function __construct(){
        $this-&gt;open_db_connection();

      }

      public function open_db_connection(){
        $this-&gt;connection = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);

          if($this-&gt;connection -&gt; connect_error){
            die('&lt;h1&gt;Database Connection Failed!!!!&lt;/h1&gt;.'. $this-&gt;connection -&gt; connect_error);
          }

      }


      private function checkQuery($query){
        if(!$query){
          die("&lt;h1&gt;Query Failed!!!!&lt;/h1&gt; ". $this-&gt;connection -&gt; error);
        }
      }

      public function query($sql){
        $result = mysqli_query($this-&gt;connection , $sql);
        $this-&gt;checkQuery($result);
        return $result;

      }

}

      $database = new Database();

?&gt;
Some tips which might help you:


Make as few static methods as possible. Those functions should not
appear in any other function as they get in a way in unit tests. I usually use them to spit out html in views.
Don't use global varibales.
Hide as implementation as you can. Make public only those things that are vital for functionality.
I consider new operator harmful as it cannot be mocked. Use dependency injection instead to provide object with all necessary data.


Last but not least I highly recommend book Clean Code by Robert C. Martin if you care about keeping your code clean.