Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: User
- * Date: 15.03.2017
- * Time: 12:18
- */
- $mysql_host = "newnor00.mysql.ukraine.com.ua"; // sql сервер
- $mysql_user = "newnor00_1031"; // пользователь
- $mysql_password = "17506396Qq"; // пароль
- $mysql_database = "newnor00_1031"; // имя базы данных chat
- $link=new mysqli($mysql_host, $mysql_user, $mysql_password,$mysql_database);
- mysqli_query($link,"SET NAMES utf8");
- if ($link->connect_errno) {
- printf("Connect failed: %s\n", $link->connect_error);
- exit();
- }
- ?>
- <!DOCTYPE html>
- <html >
- <head>
- <title></title>
- <!-- DataTables CSS -->
- <link rel="stylesheet" href="libs/bootstrap.css">
- <link rel="stylesheet" href="dataTable/jquery.dataTables.min.css">
- <meta charset="utf-8">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script src="dataTable/jquery.dataTables.min.js"></script>
- <style>
- body{
- padding:0 20px;
- }
- </style>
- </head>
- <body>
- <!--Вывод пользователей-->
- <table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th>№</th>
- <th>Название</th>
- <th>город</th>
- <th>район</th>
- <th>улица</th>
- <th>дом</th>
- </tr>
- </thead>
- <tbody>
- <?php $query="SELECT * FROM `ambulance_station`";
- if($result= $link->query($query)):
- while ($row = $result->fetch_assoc()):?>
- <tr>
- <td><?php echo $row['id'] ?></td>
- <td><?php echo $row['name'] ?></td>
- <td><?php echo $row['city'] ?></td>
- <td><?php echo $row['district'] ?></td>
- <td><?php echo $row['street'] ?></td>
- <td><?php echo $row['house'] ?></td>
- </tr>
- <?php endwhile; endif;?>
- </tbody>
- </table>
- <!--End show users-->
- <script>
- $(document).ready(function () {
- $('#submit').click(function () {
- var name =$('#name').val();
- var city =$('#city').val();
- var street=$('#street').val();
- var house=$('#house').val();
- var district=$('#district').val();
- var id=$('#id').val();
- $.ajax({
- url:"station/edit_station.php",
- type: 'post',
- dataType: "json",
- data:{
- "id": id,
- "name": name,
- "city": city,
- "street": street,
- "house": house,
- "district":district,
- },
- success:function (data) {
- alert(data);
- },
- });
- });
- });
- </script>
- <div class="container">
- <div class="row">
- <div class="col-12">
- <form method="post">
- <label for="id">Номер записи.</label>
- <input type="text" class="form-control" name="id" id="id">
- <label for="name">Название пункта.</label>
- <input type="text" class="form-control" name="name" id="name">
- <label for="city">Город</label>
- <input type="text" class="form-control" name="city" id="city">
- <label for="district">Район</label>
- <input type="text" class="form-control" name="district" id="district">
- <label for="street">Улица</label>
- <input type="text" class="form-control" name="street" id="street">
- <label for="house">Дом</label>
- <input type="text" class="form-control" name="house" id="house">
- <div class="submit btn btn-default" id="submit">Зарегистрировать</div>
- </form>
- </div>
- </div>
- </div>
- <script>
- $(document).ready(function() {
- $('#example').DataTable( {
- } );
- // $('#edit').click(function () {
- // if($('#form').css('display')=='none') {
- // $('#form').fadeIn();
- // $('#edit').text('Отменить изменение.')
- // }else{
- // $('#form').fadeOut();
- // $('#edit').text('Изменить запись')
- // }
- // })
- } );
- </script>
- </body>
- </html>
- <?php mysqli_close($link);?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement