Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Список сотрудников</title>
- </head>
- <body>
- <div class = "header">
- <img src = "img/header.png"></img>
- </div>
- <div class = "container-fluid">
- <?php
- echo "<table class = 'table table-striped'>";
- echo "<thead>
- <tr>
- <th>№</th>
- <th>ФИО</th>
- <th>Имя транслитом</th>
- <th>Дата рождения</th>
- <th>Должность</th>
- <th>Дата приёма на работу</th>
- <th>№ удостоверения</th>
- </tr>
- </thead>
- ";
- class TableRows extends RecursiveIteratorIterator {
- function __construct($it) {
- parent::__construct($it, self::LEAVES_ONLY);
- }
- function current() {
- return "<td style='width:14%;'>" . parent::current(). "</td>";
- }
- function beginChildren() {
- echo "<tr>";
- }
- function endChildren() {
- echo "</tr>" . "n";
- }
- }
- $servername = "localhost";
- $username = "user";
- $password = "password";
- $dbname = "test";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8",
- $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT number, fullname, engname,birthdaydate,
- position, recruitmentDate,id FROM employees");
- $stmt->execute();
- // set the resulting array to associative
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as
- $k=>$v) {
- echo $v;
- }
- }
- catch(PDOException $e) {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- echo "</table>";
- ?>
- </div>
- <div class = "footer">
- <img src = "img/footer.jpg"></img>
- </div>
- <link rel="stylesheet" type="text/css" href="styles.css">
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
- <script
- src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
- </script>
- <script src="//code.jquery.com/jquery-1.10.2.js"></script>
- <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement