SHARE
TWEET

Untitled

a guest Jul 17th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $servername = "localhost";
  3. $username = "user";
  4. $password = "user";
  5. $dbname = "user";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13. //Здесь все пашет отлично
  14. if($_GET['method'] == 'login'){
  15.      //return $_GET['var1'] + $_GET['var2'];
  16.     $sqlLogin = "select id from customer where login='".$_GET['login']."' and password='".$_GET['password']."'";
  17.     $sqlEmail = "select id from customer where email='".$_GET['login']."' and password='".$_GET['password']."'";
  18.     $sqlTest = "select * from customer";
  19.  
  20.     $result = $conn->query($sqlLogin);
  21.     if ($result->num_rows > 0) {
  22.         while($row = $result->fetch_assoc()) {
  23.         echo $row["id"];
  24.         }
  25.     }else {
  26.         $resultMail = $conn->query($sqlEmail);
  27.         if ($resultMail->num_rows > 0) {
  28.         while($row = $resultMail->fetch_assoc()) {
  29.             echo $row["id"];
  30.         }
  31.     }
  32. }
  33. $conn->close();
  34. }
  35.  
  36. // Таблицы order и customer находятся в одной БД метод login работает нормально. А вот getOrders не пашет
  37. if($_GET['method'] == 'getOrders'){
  38.     $sqlOrder = "select * from order where  id_client ='".$_GET['id']."' or id_executor='".$_GET['id']."'";
  39.     $result = $conn->query($sqlOrder);
  40.     $rows = array();
  41.     if ($result->num_rows > 0) {
  42.         echo "Works";
  43.         while($row = $result->fetch_assoc()) {
  44.         echo "id: " . $row["id"];
  45.         $rows[] = $row;
  46.         }
  47.     }
  48.     print json_encode($rows);
  49.     $conn->close();
  50. }
RAW Paste Data
Top