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>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <div class = "header">
- <img src = "img/header.png"></img>
- </div>
- <div class = "container">
- <?php
- echo "<table id='table_id' class = 'table table-striped'>";
- echo "<thead>
- <tr>
- <th>№</th>
- <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>" . 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,buttonid FROM employees");
- $ids = $conn->prepare("SELECT * 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="css/styles.css">-->
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
- <link rel="stylesheet" type="text/css" href="css/normalize.css">
- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
- <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
- <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">
- <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
- <script>
- $(document).ready(function() {
- $('#table_id').DataTable( {
- "language": {
- "url": "//cdn.datatables.net/plug-ins/1.10.13/i18n/Russian.json"
- }
- } );
- } );
- </script>
- <!--
- <script>
- function fullInfo(){
- var ids = <?php echo json_encode($ids); ?>;
- for (int i = 0;i<ids.length;i++){
- if (ids['buttonID'] == this.id){
- alert ("good");
- }
- }
- };
- </script>
- -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement