Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2.  
  3. //Getting the requested id
  4. $id = $_GET['id'];
  5.  
  6. //Importing database
  7. require_once('dbConnect.php');
  8.  
  9. //Creating sql query with where clause to get an specific employee
  10. $sql = "SELECT * FROM persons WHERE firstName = '$firstName' AND lastName = '$lastName' AND company = '$company';
  11.  
  12. //getting result
  13. $r = mysqli_query($con,$sql);
  14.  
  15. //pushing result to an array
  16. $result = array();
  17. $row = mysqli_fetch_array($r);
  18. array_push($result,array(
  19. "id"=>$row[id],
  20. "firstName"=>$row[firstName],
  21. "lastName"=>$row[lastName],
  22. "company"=>$row[company]
  23. ));
  24.  
  25. //displaying in json format
  26. echo json_encode(array('result'=>$result));
  27.  
  28. mysqli_close($con);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement