How to fetch data from database and display on table using PHP?
Very often we need to display data from a database on a web page. To display those data it is best to use HTML table. Today I will share how to display data from MySQL database into HTML table using PHP.
Consider,
we have a database named data,
a table named student. And inside
this table there have some data.
First create a HTML form.
A simple HTML form containing fields – Name, E-mail, phone, state and
password. On submitting the form, the data is inserted into MySQL table using
PHP code. We will fetch the inserted record present in the database table and
display those data in an HTML table.
1. Create a HTML form = First we have to create a form to insert data into database table.
Read - How to Insert Form Data into MySQL Database using PHP ?
2. Now we have to create a table inside the home.php page and fetch the inserted record present in the database table and display those data in the table.
Code -
Note - The
fetch_array() / mysqli_fetch_array() function fetches a result row as an
associative array, a numeric array, or both.
0 Comments
if you have any doubt contact me.