die("Connection failed: " . $conn->connect_error); } } function disconnect() { $this->conn->close(); } function DbLink() { echo 'Constructor called<br/>'; $this->connect(); } function findUsers() { $sql = 'SELECT * FROM users'; $result = $this->conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "id: " . $row["id"] . " - Name: " . $row["username"] . " " . $row["password"] . "<br/>"; } } else { echo "Nothing to display"; } } } $link = new DbLink(); $link->findUsers(); $link->disconnect(); ?> </body> </html>