Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Table</title>
- </head>
- <body>
- <h1>Table countries </h1>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=geography", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- //echo "Connected successfully";
- $query = "SELECT *
- FROM geography.countries;";
- $pdoStatement = $conn->prepare($query);
- $pdoStatement->execute();
- $pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
- $data = $pdoStatement->fetchAll();
- $table = "<table border = '3'>";
- $table .= "<thead>";
- $table .= "<tr>";
- $table .= "<th>Country code</th>";
- $table .= "<th>Country name</th>";
- $table .= "<th>Population</th>";
- $table .= "<th>Capital</th>";
- $table .= "</tr>";
- $table .= "</thead>";
- $table .= "<tbody>";
- for($i = 0; $i < count($data); $i++){
- $currentRow = $data[$i];
- $table .= "<tr>";
- $table .= "<td>" .$currentRow['country_code'] . "</td>";
- $table .= "<td>" .$currentRow['country_name'] . "</td>";
- $table .= "<td>" .$currentRow['population'] . "</td>";
- $table .= "<td>" .$currentRow['capital'] . "</td>";
- $table .= "</tr>";
- }
- $table .= "</tbody>";
- $table .= "</table>";
- echo $table;
- } catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- </body>
- </html><!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Table</title>
- </head>
- <body>
- <h1>Table countries </h1>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=geography", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- //echo "Connected successfully";
- $query = "SELECT *
- FROM geography.countries;";
- $pdoStatement = $conn->prepare($query);
- $pdoStatement->execute();
- $pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
- $data = $pdoStatement->fetchAll();
- $table = "<table border = '3'>";
- $table .= "<thead>";
- $table .= "<tr>";
- $table .= "<th>Country code</th>";
- $table .= "<th>Country name</th>";
- $table .= "<th>Population</th>";
- $table .= "<th>Capital</th>";
- $table .= "</tr>";
- $table .= "</thead>";
- $table .= "<tbody>";
- for($i = 0; $i < count($data); $i++){
- $currentRow = $data[$i];
- $table .= "<tr>";
- $table .= "<td>" .$currentRow['country_code'] . "</td>";
- $table .= "<td>" .$currentRow['country_name'] . "</td>";
- $table .= "<td>" .$currentRow['population'] . "</td>";
- $table .= "<td>" .$currentRow['capital'] . "</td>";
- $table .= "</tr>";
- }
- $table .= "</tbody>";
- $table .= "</table>";
- echo $table;
- } catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- </body>
- </html><!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Table</title>
- </head>
- <body>
- <h1>Table countries </h1>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=geography", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- //echo "Connected successfully";
- $query = "SELECT *
- FROM geography.countries;";
- $pdoStatement = $conn->prepare($query);
- $pdoStatement->execute();
- $pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
- $data = $pdoStatement->fetchAll();
- $table = "<table border = '3'>";
- $table .= "<thead>";
- $table .= "<tr>";
- $table .= "<th>Country code</th>";
- $table .= "<th>Country name</th>";
- $table .= "<th>Population</th>";
- $table .= "<th>Capital</th>";
- $table .= "</tr>";
- $table .= "</thead>";
- $table .= "<tbody>";
- for($i = 0; $i < count($data); $i++){
- $currentRow = $data[$i];
- $table .= "<tr>";
- $table .= "<td>" .$currentRow['country_code'] . "</td>";
- $table .= "<td>" .$currentRow['country_name'] . "</td>";
- $table .= "<td>" .$currentRow['population'] . "</td>";
- $table .= "<td>" .$currentRow['capital'] . "</td>";
- $table .= "</tr>";
- }
- $table .= "</tbody>";
- $table .= "</table>";
- echo $table;
- } catch(PDOException $e) {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment