Hello there Here we Will display all the data stored in database table in html.
For this example we use the Example code of
Php Program To Connect With Database, Create Table To Connect with database, create table and insert data to the database. And From this code below we can display the stored data.
Q.Write PHP code that retrieves all the districts from database in tabular format. Pokhara University [2012 -Spring] Course: Web Technology
Here is our info Table in Database:
For this example we use the Example code of
Php Program To Connect With Database, Create Table To Connect with database, create table and insert data to the database. And From this code below we can display the stored data.
Q.Write PHP code that retrieves all the districts from database in tabular format. Pokhara University [2012 -Spring] Course: Web Technology
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <!doctype html>
<html>
<head>
<title>All the datas from Table in Database</title>
</head>
<body>
<?php
include "connect.php";
$sql = "SELECT id,name,email FROM info";
$result = $conn->query($sql);
echo "<table border='1'>";
echo "<tr>";
echo "<th> Id </th>";
echo "<th> Name </th>";
echo "<th> Email </th>";
echo "</tr>";
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["id"]. "</td>";
echo "<td>" . $row["name"]. "</td>";
echo "<td>" . $row["email"]. "</td>";
echo "</tr>";
}
echo "<table>";
?>
</body>
</html>
|
Here is our info Table in Database:
Here is the Output of the Code Above
Id | Name | |
---|---|---|
1 | Sagar Devkota | info@devkotasagar.com.np |
2 | Ram Hari | ram@hari.com.np |
3 | Mr Bean | mr@bean.com.np |
4 | Cristiano Ronaldo | Cristiano@Ronaldo.com.np |
5 | Tom Cruise | tom@cruise.com.np |
6 | Raffey Cassidy | Raffey@Cassidy.com.np |
This is all. You can find the code in Github https://github.com/InfoDevkota/phpformmysql/tree/master (Master Branch) Issuers and pull requested are accepted.
If something is wrong or Need more clarification Please contact me: info[at]devkotasagar.com.np.