Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html>
<head>
<title>AngularJS, PHP, MySQL</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="js/app.js"></script>
<?php
include 'config.php';
$data = json_decode(file_get_contents("php://input"));
$request_type = $data->request_type;
// Get all records
if($request_type == 1){
<?php
$host = ""; /* Host name */
$user = ""; /* User */
$password = ""; /* Password */
$dbname = ""; /* Database name */
$con = mysqli_connect($host, $user, $password,$dbname);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
@hquach
hquach / app.js
Last active November 10, 2018 03:04
var fetch = angular.module('myapp', []);
fetch.controller('userCtrl', ['$scope', '$http', function ($scope, $http) {
// Get all records
$http({
method: 'post',
url: 'CRUD.php',
data: {request_type:1},
CREATE TABLE `users` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`username` varchar(80) NOT NULL,
`fname` varchar(80) NOT NULL,
`lname` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
<?php
# Fill our vars
$dbname = '';
$dbuser = '';
$dbpass = '';
$dbhost = '';
$connect = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");