AngularJS Dynamic Dropdown list using PHP
In this Post We Will Explain About is AngularJS Dynamic Dropdown list using PHP With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Dynamic and Dependent Drop Down List using AngularJS with PHPExample
In this post we will show you Best way to implement mysql – Dynamic Drop Down AngularJS and Database with JSON, hear for how to bind dropdownlist from database in angularjswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
Database
[php]
—
— Table structure for table `users`
—
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
—
— Dumping data for table `users`
—
INSERT INTO `users` (`user_id`, `user_name`) VALUES
(1, ‘Tiger Shoraf’),
(2, ‘machulita’),
(3, ‘Damedis’);
— ——————————————————–
—
— Table structure for table `employer`
—
CREATE TABLE IF NOT EXISTS `employer` (
`emp_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`emp_name` varchar(255) NOT NULL,
PRIMARY KEY (`emp_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
—
— Dumping data for table `employer`
—
INSERT INTO `employer` (`emp_id`, `user_id`, `emp_name`) VALUES
(1, 1, ‘rajan’),
(2, 1, ‘tirupati’),
(3, 1, ‘lalubha’),
(4, 2, ‘mayavati’),
(5, 2, ‘rampal’),
(6, 2, ‘bhagadi’),
(7, 3, ‘Deepak’),
(8, 3, ‘Yadav’),
(9, 3, ‘rajpal’);
[/php]
index.php
[php]
http://angular.min.js
Live24u : Dynamic Dropdown list using AngularJS in PHP
Select Users
{{users.user_name}}
Select Employers
{{employer.emp_name}}
var liveApp = angular.module(“liveApp”,[]);
liveApp.controller(“usercontroller”, function($scope, $http){
$scope.loadusers = function(){
$http.get(“load_users.php”)
.success(function(data){
$scope.userlist = data;
})
}
$scope.loademp = function(){
$http.post(“load_employers.php”, {‘user_id’:$scope.users})
.success(function(data){
$scope.emps = data;
});
}
});
[/php]
load_users.php
[php]
[/php]
load_employers.php
[php]
user_id.”‘ ORDER BY emp_name ASC”;
$data_response = mysqli_query($db_connect, $sql_query);
while($data_row = mysqli_fetch_array($data_response))
{
$res_output_array[] = $data_row;
}
echo json_encode($res_output_array);
?>
[/php]
I hope you have Got What is Dynamic Dropdown list using AngularJS with PHP And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.