Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. $db_name = 'card_site';
  3. $hostname = 'localhost';
  4. $username = 'root';
  5. $password = 'root';
  6.  
  7. $dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password);
  8.  
  9. $sql = 'SELECT ID, card_title, card_category, card_rating, card_image FROM cards';
  10.  
  11. $stmt = $dbh->prepare( $sql );
  12.  
  13. $stmt->execute();
  14.  
  15. $result = $stmt->fetchAll( PDO::FETCH_ASSOC );
  16.  
  17. $json = json_encode( $result );
  18.  
  19. echo $json;
  20. ?>
  21.  
  22. angular.module("cardSite")
  23. .service('dataService', function($http) {
  24. // DB GET function
  25. this.getCards = function() {
  26. return $http.get("scripts/data/api.php")
  27. };
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement