Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. $postdata = file_get_contents("php://input");
  2. $request = json_decode($postdata);
  3.  
  4.  
  5. $servername = "localhost";
  6. $username = "root";
  7. $password = "";
  8. $dbname = "test";
  9.  
  10.  
  11. $conn = new mysqli($servername, $username, $password, $dbname);
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }else{
  15. foreach ($request as $key => $jsons) {
  16. foreach($jsons as $key => $value) {
  17. $equip = $value['equipment'];
  18. $sql = "INSERT INTO contratos (equipo) VALUES ('$equip')";
  19. }
  20. }
  21.  
  22. $scope.continue = function(choices)
  23. {
  24. var data = $scope.choices;
  25. $http.post('php/phptest.php', data)
  26. .then(function(response) {
  27. console.log(response);
  28.  
  29.  
  30. });
  31. };
  32.  
  33. [
  34. {
  35. "id":"choice1",
  36. "quantity":1,
  37. "equipment":"BLONG - F25",
  38. "teamvox":true,
  39. "plandatos":"D50"
  40. },
  41. {
  42. "id":"choice2",
  43. "quantity":1,
  44. "equipment":"OUTERFONE - S17",
  45. "evidence":true,
  46. "mobictrl":true,
  47. "plandatos":"D100"
  48. }
  49. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement