Advertisement
basart1

Untitled

Apr 24th, 2019
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.53 KB | None | 0 0
  1.  
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <title>My Form</title>
  6. </head>
  7. <body>
  8. <table class="tab2" border="1">
  9.     <tbody id="body">
  10.     <tr>
  11.         <th><a href="?id">№</th></a>
  12.         <th><a href="?name">Имя</th></a>
  13.         <th><a href="?surn">Фамилия</th></a>
  14.         <th><a href="?phone">Номер телефона</th></a>
  15.     </tr>
  16.     <?php
  17. const HOST_NAME = '127.0.0.1';
  18. const DB_NAME = 'address_book';
  19. const LOGIN_DB = 'basart';
  20. const PASSWORD_DB = "megusta";
  21. const PORT = 3306;
  22. $mysqlConnection = new mysqli(HOST_NAME, LOGIN_DB, PASSWORD_DB, DB_NAME, PORT);
  23. function addcheck ($mysqlConnection){
  24.     $query1 = "SELECT * FROM `users` WHERE `check`= 1";
  25.     $result = mysqli_query($mysqlConnection,$query1 );
  26.      if ($ew1 =  mysqli_fetch_all($result)) {
  27.         return $ew1;
  28.     }
  29. }
  30. addcheck($mysqlConnection);
  31. if(!isset($_GET['id']) && !isset($_GET['name']) && !isset($_GET['surn']) && !isset($_GET['phone'])) {
  32.     echo "1";
  33.         foreach (addcheck($mysqlConnection) as $key => $value) {
  34.          echo
  35.     "<table class='tab2' border='2'  bgcolor='#ff7f50' width='15%'>
  36.    <tr  style='color: chartreuse'>
  37.    <tr>
  38.    <td>", $value[0], "</td>
  39.    <td>", $value[1], "</td>
  40.    <td >", $value[2], "</td>
  41.    <td>", $value[3], "</td>
  42.    </table>";
  43.     }
  44. }
  45.         if(isset($_GET['id'])) {
  46.         echo "2";
  47.         $desc = 0;
  48.         $desc=$desc +1;
  49.         $qr_result = mysqli_query($mysqlConnection,"SELECT * FROM `users` WHERE `check` = 1 ORDER BY `id` ASC");
  50.          var_dump($desc);
  51.         }if ($desc%2!=1){
  52.             $qr_result = mysqli_query($mysqlConnection,"SELECT * FROM `users` WHERE `check` = 1 ORDER BY `id` DESC");
  53.          }
  54.         if(isset($_GET['name'])) {
  55.             echo "3";
  56.             $qr_result = mysqli_query($mysqlConnection,"SELECT * FROM `users` WHERE `check` = 1 ORDER BY `first_name` ASC");
  57.         }
  58.         if(isset($_GET['surn'])) {
  59.             echo "4";
  60.             $qr_result = mysqli_query($mysqlConnection,"SELECT * FROM `users` WHERE `check` = 1 ORDER BY `surname` ASC");
  61.         }
  62.         if(isset($_GET['phone'])) {
  63.             echo "5";
  64.             $qr_result = mysqli_query($mysqlConnection,"SELECT * FROM `users` WHERE `check` = 1 ORDER BY `phone_number` ASC");
  65.         }
  66.     while ($row = mysqli_fetch_array($qr_result)){
  67.                echo
  68.     "<table class='tab2' border='2'  bgcolor='#ff7f50' width='15%'>
  69.    <tr  style='color: chartreuse'>
  70.    <tr>
  71.    <td>", $row[0], "</td>
  72.    <td>", $row[1], "</td>
  73.    <td >", $row[2], "</td>
  74.    <td>", $row[3], "</td>
  75.    </table>";
  76. }
  77.     ?>
  78.    
  79.     </tr>
  80.     </tbody>
  81. </table>
  82. <input type="button" value="Добавить" id="btnTrigger"/>
  83. <input type="button" value="Удалить всё" id="deleteAllRows"/>
  84. <form class="form" action="form.php" method="post" id="form">
  85.     <p>My form</p>
  86.     <fieldset>
  87.         <legend>Запись данных</legend>
  88.         <p><label for="name">Имя <em>*</em></label><input  type="text" id="name" name="name"></p>
  89.         <p><label for="surname">Фамилия<em>*</em></label><input  type="text" id="surname"
  90.                                                                 name="surname"></p>
  91.         <p><label for="phonenumber">Номер телефона<em>*</em></label><input  type="text" id="pn"
  92.                                                                            name="pn"></p>
  93.         <input type="submit" value="Добавить"  id="btnAdd"/>
  94.  
  95.     </fieldset>
  96. <!--<script src="ajax.js" charset="utf-8"></script>-->
  97. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement