So you are having a Database and wants your users to view that data comfortably in a web browser.
In this post we will see how this is done along with an example.
Let us say that you have a database named "diwali" with a table which is also named "diwali" and you want to list all the fields in a suitable format in a web browser.
Let us say we have sno, name, email and phone no of a user stored in our database.
We can then use following code in our php to print the values of these fields :
<?php
// Connect to server and select database.
$host = "localhost";
$username = "root";
$password = "";
$db_name="diwali";
// Connect to server and select database.
$conn = new mysqli($host, $username, $password,$db_name);
$connectionHandle = mysqli_connect($host, $username, $password, $db_name);
$getQuery = "SELECT * FROM diwali ORDER BY sno ;";
$handle = mysqli_query($connectionHandle, $getQuery);
?>
<?php
while($row = mysqli_fetch_array($handle)){
echo '
<tr>
<td>'.$row['sno'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['email'].'</td>
<td>'.$row['phone'].'</td>
</tr>';
}
?>