Advertisement
Guest User

Untitled

a guest
Mar 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.35 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: User
  5. * Date: 15.03.2017
  6. * Time: 12:18
  7. */
  8. $mysql_host = "newnor00.mysql.ukraine.com.ua"; // sql сервер
  9. $mysql_user = "newnor00_1031"; // пользователь
  10. $mysql_password = "17506396Qq"; // пароль
  11. $mysql_database = "newnor00_1031"; // имя базы данных chat
  12.  
  13.  
  14. $link=new mysqli($mysql_host, $mysql_user, $mysql_password,$mysql_database);
  15. mysqli_query($link,"SET NAMES utf8");
  16. if ($link->connect_errno) {
  17.     printf("Connect failed: %s\n", $link->connect_error);
  18.     exit();
  19. }
  20. ?>
  21.  
  22. <!DOCTYPE html>
  23. <html >
  24.  
  25. <head>
  26.     <title></title>
  27.     <!-- DataTables CSS -->
  28.     <link rel="stylesheet" href="libs/bootstrap.css">
  29.     <link rel="stylesheet" href="dataTable/jquery.dataTables.min.css">
  30.     <meta charset="utf-8">
  31.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  32.     <script src="dataTable/jquery.dataTables.min.js"></script>
  33.     <style>
  34.         body{
  35.             padding:0 20px;
  36.         }
  37.     </style>
  38. </head>
  39.  
  40. <body>
  41. <!--Вывод пользователей-->
  42. <table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
  43. <thead>
  44. <tr>
  45.     <th></th>
  46.     <th>Название</th>
  47.     <th>город</th>
  48.     <th>район</th>
  49.     <th>улица</th>
  50.     <th>дом</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <?php $query="SELECT * FROM `ambulance_station`";
  55. if($result= $link->query($query)):
  56.     while ($row = $result->fetch_assoc()):?>
  57.         <tr>
  58.         <td><?php echo $row['id'] ?></td>
  59.         <td><?php echo $row['name'] ?></td>
  60.         <td><?php echo $row['city'] ?></td>
  61.         <td><?php echo $row['district'] ?></td>
  62.         <td><?php echo $row['street'] ?></td>
  63.         <td><?php echo $row['house'] ?></td>
  64.         </tr>
  65. <?php endwhile; endif;?>
  66. </tbody>
  67. </table>
  68. <!--End show users-->
  69. <script>
  70.     $(document).ready(function () {
  71.         $('#submit').click(function () {
  72.             var name =$('#name').val();
  73.             var city =$('#city').val();
  74.             var street=$('#street').val();
  75.             var house=$('#house').val();
  76.             var district=$('#district').val();
  77.             var id=$('#id').val();
  78.             $.ajax({
  79.                 url:"station/edit_station.php",
  80.                 type: 'post',
  81.                 dataType: "json",
  82.                 data:{
  83.                     "id": id,
  84.                     "name": name,
  85.                     "city": city,
  86.                     "street": street,
  87.                     "house": house,
  88.                     "district":district,
  89.                 },
  90.                 success:function (data) {
  91.                     alert(data);
  92.                 },
  93.             });
  94.         });
  95.     });
  96. </script>
  97. <div class="container">
  98.     <div class="row">
  99.         <div class="col-12">
  100.             <form method="post">
  101.                 <label for="id">Номер записи.</label>
  102.                 <input type="text" class="form-control" name="id" id="id">
  103.                 <label for="name">Название пункта.</label>
  104.                 <input type="text" class="form-control" name="name" id="name">
  105.                 <label for="city">Город</label>
  106.                 <input type="text" class="form-control" name="city" id="city">
  107.                 <label for="district">Район</label>
  108.                 <input type="text" class="form-control" name="district" id="district">
  109.                 <label for="street">Улица</label>
  110.                 <input type="text" class="form-control" name="street" id="street">
  111.                 <label for="house">Дом</label>
  112.                 <input type="text" class="form-control" name="house" id="house">
  113.                 <div class="submit btn btn-default" id="submit">Зарегистрировать</div>
  114.             </form>
  115.         </div>
  116.     </div>
  117. </div>
  118.  
  119. <script>
  120.     $(document).ready(function() {
  121.         $('#example').DataTable( {
  122.  
  123.         } );
  124. //        $('#edit').click(function () {
  125. //            if($('#form').css('display')=='none') {
  126. //                $('#form').fadeIn();
  127. //                $('#edit').text('Отменить изменение.')
  128. //            }else{
  129. //                $('#form').fadeOut();
  130. //                $('#edit').text('Изменить запись')
  131. //            }
  132. //        })
  133.     } );
  134. </script>
  135. </body>
  136. </html>
  137. <?php mysqli_close($link);?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement