Display record from database in table form using PHP



To display record we are going to use select query to fetch record from database. It will show record in table form.

Syntax :

    "SELECT * FROM Table_name"

Below is code to display record. It is retrive.php

<!--Display record from database -->
<!DOCTYPE html>
<html>
<head>
    <title>retrive data from database</title>
</head>
<body>
<?php
$conn=new mysqli('localhost','root','','vibha');
   
    $data="SELECT * FROM registration";
    $result=mysqli_query($conn,$data);
?>

<table border="1" width="600">
    <tr>
        <th>id</th>
        <th>FirstName</th>
        <th>LastName</th>
        <th>Email</th>
        <th>MobileNo</th>
        <th>Delete</th>
        <th>Edit</th>

    </tr>
<tr>
    <?php
        while ($record=mysqli_fetch_array($result))
         {
            $id=$record['id'];
            $Fname=$record['FirstName'];
            $Lname=$record['LastName'];
            $Email=$record['Email'];
            $Mobile=$record['MobileNo'];    

       
    ?>
    <td><?php echo $id; ?></td>
    <td><?php echo $Fname;?></td>
    <td><?php echo $Lname; ?></td>
    <td><?php echo $Email; ?></td>
    <td><?php echo $Mobile; ?></td>
    <td><a href="delete.php?del=<?php echo $id ?>"><input type=
    "submit" name="submit" value="delete"></a></td>
    <td><a href="edit.php?id=<?php echo $id ?>"><input type=
    "submit" name="submit" value="edit"></a></td>
</tr>
<?php } ?>  
</table>
</body>
</html>



Comments

Popular posts from this blog

Python