Advertisement
Guest User

aayush

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