Guest User

Untitled

a guest
Dec 18th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_GET['phone']))
  4. {
  5. $db_server = "localhost";
  6. $db_username = "username";
  7. $db_password = "password";
  8. $db_database = "dbName";
  9.  
  10. $conn = new PDO("mysql:host=$db_server;dbname=$db_database", $db_username, $db_password);
  11. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12. $search_query=$_GET['phone'];
  13.  
  14. $sql = 'SELECT receipt,phonenumber,transday FROM transactions where MATCH(phonenumber) AGAINST(:search_query)';
  15.  
  16. $statement = $conn->prepare($sql);
  17. // echo $statement;
  18. $statement->bindParam(':search_query', $search_query, PDO::PARAM_STR);
  19. $statement->execute();
  20.  
  21. if($statement->rowCount())
  22. {
  23. $row_all = $statement->fetchall(PDO::FETCH_ASSOC);
  24. header('Content-type: application/json');
  25. echo json_encode($row_all);
  26.  
  27. }
  28. elseif(!$statement->rowCount())
  29. {
  30. $error = "No Data Found For This User \n";
  31. header('Content-type: application/json');
  32. echo json_encode($error);
  33. }
  34.  
  35.  
  36. }
  37.  
  38. ?>
Add Comment
Please, Sign In to add comment