Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db_name = 'card_site';
- $hostname = 'localhost';
- $username = 'root';
- $password = 'root';
- $dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password);
- $sql = 'SELECT ID, card_title, card_category, card_rating, card_image FROM cards';
- $stmt = $dbh->prepare( $sql );
- $stmt->execute();
- $result = $stmt->fetchAll( PDO::FETCH_ASSOC );
- $json = json_encode( $result );
- echo $json;
- ?>
- angular.module("cardSite")
- .service('dataService', function($http) {
- // DB GET function
- this.getCards = function() {
- return $http.get("scripts/data/api.php")
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement