Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Список сотрудников</title>
  6.  
  7. </head>
  8. <body>
  9.  
  10. <div class = "header">
  11. <img src = "img/header.png"></img>
  12. </div>
  13.  
  14. <div class = "container-fluid">
  15. <?php
  16.  
  17. echo "<table class = 'table table-striped'>";
  18. echo "<thead>
  19. <tr>
  20. <th>№</th>
  21. <th>ФИО</th>
  22. <th>Имя транслитом</th>
  23. <th>Дата рождения</th>
  24. <th>Должность</th>
  25. <th>Дата приёма на работу</th>
  26. <th>№ удостоверения</th>
  27. </tr>
  28. </thead>
  29. ";
  30.  
  31. class TableRows extends RecursiveIteratorIterator {
  32. function __construct($it) {
  33. parent::__construct($it, self::LEAVES_ONLY);
  34. }
  35.  
  36. function current() {
  37. return "<td style='width:14%;'>" . parent::current(). "</td>";
  38. }
  39.  
  40. function beginChildren() {
  41. echo "<tr>";
  42. }
  43.  
  44. function endChildren() {
  45. echo "</tr>" . "n";
  46. }
  47. }
  48.  
  49. $servername = "localhost";
  50. $username = "user";
  51. $password = "password";
  52. $dbname = "test";
  53.  
  54. try {
  55. $conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8",
  56. $username, $password);
  57. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  58. $stmt = $conn->prepare("SELECT number, fullname, engname,birthdaydate,
  59. position, recruitmentDate,id FROM employees");
  60. $stmt->execute();
  61.  
  62. // set the resulting array to associative
  63. $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  64. foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as
  65. $k=>$v) {
  66. echo $v;
  67. }
  68. }
  69. catch(PDOException $e) {
  70. echo "Error: " . $e->getMessage();
  71. }
  72. $conn = null;
  73. echo "</table>";
  74. ?>
  75. </div>
  76. <div class = "footer">
  77. <img src = "img/footer.jpg"></img>
  78. </div>
  79.  
  80. <link rel="stylesheet" type="text/css" href="styles.css">
  81. <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  82. <script
  83. src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
  84. </script>
  85. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  86. <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
  87.  
  88. </body>
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement