Advertisement
Guest User

Untitled

a guest
Mar 13th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.95 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  <title>Table with database</title>
  5.  <style>
  6.   table {
  7.    border-collapse: collapse;
  8.    width: 100%;
  9.    color: #588c7e;
  10.    font-family: monospace;
  11.    font-size: 25px;
  12.    text-align: left;
  13.      }
  14.   th {
  15.    background-color: #588c7e;
  16.    color: white;
  17.     }
  18.   tr:nth-child(even) {background-color: #f2f2f2}
  19.  </style>
  20. </head>
  21. <body>
  22.  <table>
  23.  <tr>
  24.   <th>Id</th>
  25.   <th>Username</th>
  26.   <th>Password</th>
  27.  </tr>
  28.  <?php
  29. $servername = "localhost";
  30. $username = "root";
  31. $password = "";
  32.  
  33. try {
  34.     $conn = new PDO("mysql:host=$servername;dbname=mydb", $username, $password);
  35.     // set the PDO error mode to exception
  36.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  37.      echo "Connected successfully";
  38.      }
  39.  catch(PDOException $e)
  40.      {
  41.      echo "Connection failed: " . $e->getMessage();
  42.      }
  43.  
  44.  $sql = "SELECT nume, prenume, varsta FROM sudenti";
  45.  ?>
  46.  
  47. </table>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement