Today, We want to share with you how to retrieve data from database in html form.In this post we will show you how to fetch data from database in php and display in html table, hear for Retrieve data from database and display in php form we will give you demo and example for implement.In this post, we will learn about how to fetch data from database in php and display in textbox with an example.
Retrieve data from database and display in php form
As we already display “how to insert data in mysql using php form“. But if want to edit some details in that form how will We do that? must We quickly update form without viewing the old data? Or must We check my old data first as well as then update or change each all data? also you can check how to fetch data from database in php using mysqli?
Answer is clear that early We have to look at old data then We will update or change that. But how to get data and display in HTML form
Don’t worry in this Article We are going to show how to retrieve data from database with display in php form.
We are returning Our foregoing example of insert data. In that Article We Made a HTML form with product_name and content field only. So this time We are not going to make MySQL database as well as table because We already Made both of them in Our preceding Article.
Create database connection:
database.php
Retrieve Data from Database:
For retrieve data from MySQL the SELECT Query statement is used. We can get data from each Table DB column or all column of a DB table.
To get selected each column data from database Table the MySQL query is
SELECT column_name,column_name FROM products;
To get all the column data from a table the MySQL query is
SELECT * FROM products;
Retrieve Data From MySQL Using PHP
In above php source code We get the database record which id is 1. using mysqli_fetch_assoc() function will return that specific database table record as an array datatype (which holds product_name and details) and We save that array in $getProductList variable.
FORM HTML:
Now We get the database record from the database Table This is a time to display each DB table column like as product_desc, name, title, price, handle, brand or many more data into its respective all DB fields.
Add Product
Included CSS:
body{font-family:verdana;} .container{width:500px;margin: 0 auto;} h3{line-height:19px;font-size:19px;} input{display:block;width:360px;height:19px;margin:11px 0;} textarea{display:block;width:360px;margin:11px 0;} button{background:green; border:1px solid green;width:70px;height:30px;color:#ffffff}
Complete Source Code
Get or Retrieve data from database and display in php form - www.pakainfo.com Edit Product
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about how to retrieve data from database in html form.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.