Advertisement
Guest User

Untitled

a guest
Jan 15th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. var carregarUsuario = function () {
  2. $http.get("buscar.php").then(function (retorno){
  3. console.log(retorno.data);
  4. $scope.usuarios = retorno.data;
  5. });
  6. };
  7. carregarUsuario();
  8.  
  9. error_reporting(0);
  10. $user = "root";
  11. $password = "";
  12. $db = "angulardb";
  13. $host = "localhost";
  14. $con = mysqli_connect("localhost", $user, $password, $db);
  15. if (mysqli_connect_errno()){
  16. echo "Erro: " . mysqli_connect_error();
  17. }
  18. $usuario = mysqli_query($con, "SELECT * FROM users");
  19.  
  20. header('Content-Type: application/json');
  21. $return = array();
  22.  
  23. while ($dados = mysqli_fetch_assoc($usuario)) {
  24. array_push($return, $dados);
  25. }
  26.  
  27. echo json_encode($return);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement