Show All Data From Database in Php
<?php
include'dbconnect.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Show</title>
<style>
th{
background:black;
color:white;
text-align:center;
}
td:nth-child(even){
background:red;
color:white;
text-align:center;
}
td:nth-child(odd){
background:green;
color:white;
text-align:center;
}
</style>
</head>
<body>
<h1>Show data from Database</h1>
<table border="1" width="100%" rules="" cellspacing="4" cellpadding="4">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Father Name</th>
<th>Mobile</th>
<th>Email</th>
<th>Password</th>
<th>Course</th>
<th>Gender</th>
<th>File</th>
<th colspan="2">Edit/Delete</th>
</tr>
</thead>
<tbody>
<?php
$sql="select * from tbl_user";
$result=mysqli_query($con,$sql);
$count=mysqli_num_rows($result);
if($count>0){
while($data=mysqli_fetch_assoc($result)){
?>
<tr>
<td><?php echo $data['id']?></td>
<td><?php echo $data['Name']?></td>
<td><?php echo $data['Father']?></td>
<td><?php echo $data['Mobile']?></td>
<td><?php echo $data['Email']?></td>
<td><?php echo $data['Password']?></td>
<td><?php echo $data['Course']?></td>
<td><?php echo $data['Gender']?></td>
<td><?php echo $data['File']?></td>
<td>
<a href="edit.php?/=<?php echo $data['id'];?>" style="color:green;text-decoration:none">Edit</a>
</td>
<td>
<a href="delete.php?/=<?php echo $data['id'];?>" onclick="return confirm('DO you sure delete the data')" style="color:red;text-decoration:none">Delete</a>
</td>
</tr>
</tbody>
<?php
}
}else{
?>
<tr>
<td colspan="10"><?php echo "NO record Found;"?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
0 Comments