How to view phpMyAdmin data in html page | How to get database data in html page

 


 

We have following data in our database. 





Let's create a PHP file to view it on our webpage

database.php

<h1>List of Contact</h1>

<table border="2">
<tr>
<th>Id</th>
<th>Email</th> 
<th>Username</th>
<th>Password</th> 
</tr>

<?php
include 'config.php';
$sql = "SELECT * FROM names";

$result = mysqli_query($conn, $sql);

if ($result) {
    while($row = mysqli_fetch_assoc($result)){
        $id = $row['id']; // first column of database table
        $email = $row['email']; // second column database table
        $username = $row['username']; // third column database table
        $password = $row['password']; // fourth column database table

?>
<tr>
<td><?php echo $id  ?></td>
<td><?php echo $email  ?></td>
<td><?php echo $username  ?></td>
<td><?php echo $password  ?></td>
</tr>

<?php

    }
}

?>
</table>


Output :

For more information you can read this documentation of PHP and MySQL.


PHP:

PHP is a server-side programming language used to create dynamic web pages and static sites. It is trendy for the beck-end due to many built-in tools and modules for developing various applications. It is open source and licensed. Website development in PHP is available for both experienced developers and beginners. PHP is a simple language. You can make your blog in just two to three weeks of learning. Plus, on a freelance, it is more in demand.

Key features of PHP:

  • open-source server-side scripting language
  • cross-platform
  • short learning curve
  • in-built support for working with MySQL

Disadvantages:

  • used primarily in web development
  • weak typing
  • awkward standard library


MySQL:

MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language. It is a relational database management system based on SQL – Structured Query Language. The application is used for a wide range of purposes, including data warehousing, e-commerce, and logging applications.


Post a Comment

0 Comments