Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "bit2018";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM students";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0)
- {
- ?>
- <table border="1" width="600px" height="500px">
- <tr>
- <th>S.No.</th>
- <th>Full Name</th>
- <th>Roll No</th>
- <th>Contact</th>
- <th>Address</th>
- <th>Action</th>
- </tr>
- <?php
- // output data of each row
- $i =1;
- while($row = mysqli_fetch_assoc($result))
- {
- ?>
- <tr>
- <td><?php echo $i; $i++; ?></td>
- <td><?php echo $row['std_fname']." ".$row['std_lname']; ?></td>
- <td><?php echo $row['std_roll']; ?></td>
- <td><?php echo $row['std_contact'];?></td>
- <td><?php echo $row['std_address'];?></td>
- <td>
- <a href="update.php?id=<?php echo $row['std_id'];?>">Edit</a>
- <a href="delete.php?id=<?php echo $row['std_id'];?>">Delete</a>
- </td>
- </tr>
- <?php
- }
- }
- else
- { ?>
- <tr>
- <td colspan="5"> No Records Found</td>
- </tr>
- <?php
- }
- mysqli_close($conn);
- ?>
- </table>
Add Comment
Please, Sign In to add comment