Guest User

select

a guest
Feb 15th, 2018
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "bit2018";
  6.  
  7. // Create connection
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9. // Check connection
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13.  
  14. $sql = "SELECT * FROM students";
  15. $result = mysqli_query($conn, $sql);
  16.  
  17. if (mysqli_num_rows($result) > 0)
  18. {
  19.  
  20. ?>
  21. <table border="1" width="600px" height="500px">
  22. <tr>
  23. <th>S.No.</th>
  24. <th>Full Name</th>
  25. <th>Roll No</th>
  26. <th>Contact</th>
  27. <th>Address</th>
  28. <th>Action</th>
  29. </tr>
  30. <?php
  31. // output data of each row
  32. $i =1;
  33. while($row = mysqli_fetch_assoc($result))
  34. {
  35. ?>
  36. <tr>
  37. <td><?php echo $i; $i++; ?></td>
  38. <td><?php echo $row['std_fname']." ".$row['std_lname']; ?></td>
  39. <td><?php echo $row['std_roll']; ?></td>
  40. <td><?php echo $row['std_contact'];?></td>
  41. <td><?php echo $row['std_address'];?></td>
  42. <td>
  43. <a href="update.php?id=<?php echo $row['std_id'];?>">Edit</a>
  44. <a href="delete.php?id=<?php echo $row['std_id'];?>">Delete</a>
  45. </td>
  46. </tr>
  47. <?php
  48. }
  49.  
  50. }
  51. else
  52. { ?>
  53. <tr>
  54. <td colspan="5"> No Records Found</td>
  55. </tr>
  56. <?php
  57. }
  58.  
  59. mysqli_close($conn);
  60. ?>
  61. </table>
Add Comment
Please, Sign In to add comment