We will display all the data in table on user-list.php
<?php include("fetch.php"); ?>
<?php include("common/header.php"); ?>
<body>
<!-- Empty Table -->
<div class="container-fluid" style="margin-top: 50px;">
<div class="container w-75">
<h3>User List</h3>
<table class="table table-striped">
<thead class="bg-dark text-white">
<tr>
<th>Id </th>
<th>First name</th>
<th>Last Name </th>
<th>Username </th>
<th>email </th>
<th>Action </th>
</tr>
</thead>
<tbody>
<tr>
<td> ......... </td>
<td> ......... </td>
<td> ......... </td>
<td> ......... <td>
<td> ......... </td>
<td>
<a class="btn btn-info" href="#">View </a>
<a class="btn btn-success" href="#">Edit </a>
<a class="btn btn-danger" href="#" >Delete </a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php include("common/footer.php"); ?>
$dbhost ="localhost";
$dbuser ="root";
$dbpswd ="";
$dbname ="dbdemo";
$dbcon= mysqli_connect($dbhost,$dbuser,$dbpswd,$dbname);
if($dbcon){
//echo "Connected............!!!";
return $dbcon;
exit();
}else{
die("Connection failed ? ? ?". mysqli_error($dbcon));
}
mysqli_close($dbcon);
<?php include("dbcon.php"); //This is database connection file
$success=''; $error='';
$sql = "SELECT * FROM users";
$run = mysqli_query($dbcon,$sql);
//we have to include this file on index.php and implement all variable inside table
mysqli_close($dbcon);
<?php include("fetch.php"); ?>
<?php include("common/header.php"); ?>
<body>
<div class="container-fluid" style="margin-top: 50px;">
<div class="text-center"> <?php echo $success; ?> <?php echo $error; ?> </div>
<?php
// Message will be displayed when user will be deleted
if(isset($_GET['1'])){
echo $_GET['1'];
header( "refresh:2;url=index.php" );
}
if(isset($_GET['0'])){
echo $_GET['0'];
header( "refresh:2;url=index.php" );
}
?>
<div class="container w-75">
<h3>User List</h3>
<table class="table table-striped">
<thead class="bg-dark text-white">
<tr>
<th>Id </th>
<th>First name</th>
<th>Last Name </th>
<th>Username </th>
<th>email </th>
<th colspan="2">Action </th>
</tr>
</thead>
<tbody>
<?php while($data = mysqli_fetch_array($run)){ ?> <!-- $run variable coming from fetch.php -->
<tr>
<td> <?php echo $data['id']; ?> </td> <!-- the index value ['id'] is from database table -->
<td> <?php echo $data['fname']; ?> </td> <!-- the index value ['fname'] is from database -->
<td> <?php echo $data['lname']; ?> </td> <!-- the index value ['']fname is from database -->
<td> <?php echo $data['username']; ?> </td> <!-- the index value ['ussername'] is from database -->
<td> <?php echo $data['email']; ?> </td> <!-- the index value ['email'] is from database -->
<td>
<!-- This part is for view, update and delete for single data -->
<a class="btn btn-info " href="view.php?view_id=<?php echo $data['id']; ?>">View</a>
<a class="btn btn-success" href="update-form.php?edit_id=<?php echo $data['id']; ?>">Edit</a>
<a class="btn btn-danger" href="delete.php?del_id=<?php echo $data['id']; ?>">Delete</a>
<td>
<tr>
<?php } ?>
<tbody>
</table>
</div>
</div>
<?php include("common/footer.php"); ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<title>Codetechinfo</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<nav class="navbar navbar-expand-lg navbar-light bg-primary text-white fixed-top">
<a class="navbar-brand text-white" href="./index.php">Learn PHP </a>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link text-white" href="./index.php">Home </a>
</li>
</ul>
</div>
</nav>
<br><br>
<div class="copyright py-4 text-center text-white">
<div class="container "><small>© Copyright 2025 by Saten Chauhan</small> </div>
</div>
</body>
</html>