Server Code PHP and MySQL
PHP
<?php header( "Access-Control-Allow-Origin: *" ); header( "Content-Type: application/json; charset=UTF-8" ); $connection = new mysqli( "myServer" , "<username>" , "<password>" , "<dbname>" ); $result = $connection ->query( "SELECT EmployeeName, EmployeeCity, EmployeeCountry FROM Employees" ); $output = "" ; while ( $rs = $result ->fetch_array(MYSQLI_ASSOC)) { if ( $output != "" ) { $output = ", " ; } $output .= '{"Name":"' . $rs ["EmployeeName "] . '" , '; $output .= '"City":"' . $rs ["EmployeeCity "] . '" , '; $output .= '"Country":"' . $rs ["EmployeeCountry "] . '" }'; } $output = '{"records":[' . $output . ']}' ; $connection ->close(); echo $output ; ?> |
Assume that the Employees table is having 6 records and they are in MySQL. PHP code retrieves the data from MySQL in the format of JSON and angular JS displays the output.
Output:
AngularJS SQL
In any web application, we need to save, update, insert and fetch data to and from a database. AngularJS is a JavaScript MVC (Model-View-Controller) framework developed by Google. It helps developers to build well-structured, easily testable, and maintainable front-end applications.
Important Features in AngularJS Library are given below:
- Concept
- Template
- Directives
- Model
- Scope
- Expressions
- Compiler
- Filter
- Data Binding
- Controller
- Module
- Service
Contact Us