Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Список сотрудников</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. </head>
  8. <body>
  9.  
  10. <div class = "header">
  11. <img src = "img/header.png"></img>
  12. </div>
  13.  
  14. <div class = "container">
  15. <?php
  16.  
  17. echo "<table id='table_id' 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. <th>Полная информация</th>
  28. </tr>
  29. </thead>
  30. ";
  31.  
  32. class TableRows extends RecursiveIteratorIterator {
  33. function __construct($it) {
  34. parent::__construct($it, self::LEAVES_ONLY);
  35. }
  36.  
  37. function current() {
  38. return "<td>" . parent::current(). "</td>";
  39. }
  40.  
  41. function beginChildren() {
  42. echo "<tr>";
  43. }
  44.  
  45. function endChildren() {
  46. echo "</tr>" . "n";
  47. }
  48. }
  49.  
  50. $servername = "localhost";
  51. $username = "user";
  52. $password = "password";
  53. $dbname = "test";
  54.  
  55. try {
  56. $conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password);
  57. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  58. $stmt = $conn->prepare("SELECT number, fullname, engname,birthdaydate, position, recruitmentDate,id,buttonid FROM employees");
  59. $ids = $conn->prepare("SELECT * 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 $k=>$v) {
  65. echo $v;
  66. }
  67. }
  68. catch(PDOException $e) {
  69. echo "Error: " . $e->getMessage();
  70. }
  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="css/styles.css">-->
  81. <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  82. <link rel="stylesheet" type="text/css" href="css/normalize.css">
  83. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
  84. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js">
  85. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  86. <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  87. <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
  88. <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">
  89. <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
  90. <script>
  91.  
  92. $(document).ready(function() {
  93. $('#table_id').DataTable( {
  94. "language": {
  95. "url": "//cdn.datatables.net/plug-ins/1.10.13/i18n/Russian.json"
  96. }
  97. } );
  98.  
  99.  
  100.  
  101. } );
  102. </script>
  103. <!--
  104. <script>
  105. function fullInfo(){
  106. var ids = <?php echo json_encode($ids); ?>;
  107. for (int i = 0;i<ids.length;i++){
  108. if (ids['buttonID'] == this.id){
  109. alert ("good");
  110. }
  111. }
  112. };
  113. </script>
  114. -->
  115.  
  116. </body>
  117. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement