Guest User

Untitled

a guest
May 24th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. //1. Database conecction
  3. $dbhost = "localhost";
  4. $dbuser = "josepojw_Trainer";
  5. $dbpass = "locker011";
  6. $dbname = "josepojw_Testing";
  7. $connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  8.  
  9.  
  10. //Test is connection works
  11. if(mysqli_connect_errno()){
  12. die("connection failed" . mysqli_connect_error() . "(". mysqli_connect_errno() .")");
  13. }
  14. ?>
  15.  
  16. <?php
  17. //2. Perform query
  18. $query = "SELECT * FROM login";
  19. $result = mysqli_query($connection, $query);
  20. //test if query error
  21. if(!$result){
  22. die("query failed");
  23. }
  24. ?>
  25.  
  26. <?php
  27. //3.Use returned data
  28. while($row = mysqli_fetch_row($result)){
  29. //get the first row and assign to the variable, loop increment
  30. var_dump($row);
  31. //output from each row
  32. echo "<hr />";
  33. //horizontal line tag
  34. }
  35. ?>
  36. <?php
  37. //4. Release the data
  38. mysqli_free_result($result);
  39. ?>
  40.  
  41. <!DOCTYPE html>
  42. <html>
  43. <head>
  44. <title>database</title>
  45. </head>
  46. <body>
  47.  
  48. </body>
  49. </html>
  50.  
  51. <?php
  52. //5. Close the connection
  53. mysqli_close($connection);
  54.  
  55. ?>
Add Comment
Please, Sign In to add comment