Posts

Showing posts from July, 2024

Displaying Database data using Class, Object, Constructor, Destructor in PHP MySql

Image
  <?php class Employee {     private $conn ;     public function __construct ()     {         $this -> conn = new mysqli ( "localhost" , "root" , "" , "database_ci" );         if ( $this -> conn -> connect_error ) {             die ( "Connection Failed : " . $this -> conn -> connect_error );         }     }     public function __destruct ()     {         $this -> conn -> close ();     }     public function getAllEmployees ()     {         $data = [];         $sql = " SELECT * FROM register " ;         $result = $this -> conn -> query ( $sql );         if ( $result -> num_rows > 0 ) {             while ( $row = $result -...