Fetch data from MySQL using OOP - phptpoint

Fetch data from MySQL using OOP

/ins>

How to Fetch data from database Using OOPS in php

We have already created a class i.e “Database”. Add new fields to admin table like Emailid, Mobile etc and insert data into these fields.

Add a new method to this class displayall(), and pass an argument for table name. Connect the database through $this keyword, make a table to get the user’s data in a tabular form.

then make a sql query to get all records of a user. Start while loop, with the help of $res variable print user’s data i.e Username, EmailId, Password & Mobile No.

Database Class and displayall() method

Create Object of class database and Call displayall() method