Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>Example 71</title>
  6. </head>
  7. <body>
  8. <?php
  9. # Connect to a database and access a table
  10.  
  11. $dbname = 'ce154_ss18960'; // Please set this to your database, e.g. ce154_username
  12. $dbuser = 'root';
  13. $dbpass = "";
  14. $dbhost = 'localhost';
  15.  
  16. $link = mysqli_connect( $dbhost, $dbuser, $dbpass )
  17. or die( "Unable to Connect to '$dbhost'" );
  18.  
  19. mysqli_select_db( $link, $dbname )
  20. or die("Could not open the db '$dbname'");
  21.  
  22. $test_query = "select * from Demonstration";
  23. $result = mysqli_query( $link, $test_query );
  24.  
  25. while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) )
  26. {
  27. echo $row[ 'firstname' ], ' ', $row[ 'lastname' ], ' ',
  28. $row[ 'email' ], "<br />\n";
  29. }
  30.  
  31. mysqli_free_result( $result );
  32. mysqli_close( $link );
  33. ?>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement