Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Table with database</title>
- <style>
- table {
- border-collapse: collapse;
- width: 100%;
- color: #588c7e;
- font-family: monospace;
- font-size: 25px;
- text-align: left;
- }
- th {
- background-color: #588c7e;
- color: white;
- }
- tr:nth-child(even) {background-color: #f2f2f2}
- </style>
- </head>
- <body>
- <table>
- <tr>
- <th>Id</th>
- <th>Username</th>
- <th>Password</th>
- </tr>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=mydb", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- $sql = "SELECT nume, prenume, varsta FROM sudenti";
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement