Guest User

Untitled

a guest
Dec 29th, 2018
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4. $servername = "localhost";
  5. $username="root";
  6. $password="";
  7. $dbname="name";
  8.  
  9. // Create connection
  10. $conn=new mysqli($servername,$username,$password,$dbname);
  11. // check connection
  12. if($conn->connect_error){
  13. die("Connection Failed" .$conn->connection_error);
  14. }
  15.  
  16. $sql="SELECT student_code,name,age FROM student";
  17. $result=$conn->query($sql);
  18.  
  19. if($result->num_rows >0)
  20. {
  21. //output data of each row
  22.  
  23. while($row=$result->fetch_assoc()){
  24. echo "student code:".$row["student_code"]."-<br>name:".$row["name"]."<br>age".$row["age"]."<br><br><br>";
  25. }
  26. }else{
  27. echo "0 results";
  28. }
  29. $conn->close();
  30. ?>
  31. </body>
  32. </html>
Add Comment
Please, Sign In to add comment