Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select value="center_name" ng-model="selectedname" ng-options="name.center_name for name in namelist" ng-change="loadcounsellors(selectedname)">
- <option >Please select a name</option>
- </select>
- var app=angular.module('myapp',[]);
- app.controller('MyCtrl',function($scope,$http,$httpParamSerializer)
- {
- $http.get("logintype.php")
- .then(function(response)
- {
- $scope.namelist=response.data;
- })
- $scope.loadcounsellors=function(item){
- alert(item.center_name);
- $http.post("counselorlist.php",$httpParamSerializer({center_name:item.center_name}))
- .then(function(response)
- {
- // alert("hello world");
- $scope.counsellor=response.data;
- alert(response.data);
- })
- }
- })
- <h2>Selected: {{counsellor}}</h2>
- <?php
- require "connection.php";
- // $postdata = file_get_contents("php://input");
- // $params = json_decode(file_get_contents('php://input'), true);
- // $request1 = json_decode($postdata);
- // echo $request1;
- $center_name = $_POST['center_name'];
- echo $center_name;
- // $center_name = "Andheri"; //This works fine.
- $query = "select distinct(edited_by) from telephonic_enquiry
- where center_name='$center_name'";
- $result = mysqli_query($conn, $query);
- if (mysqli_num_rows($result)>0 ) {
- $response=array();
- while ($row= mysqli_fetch_array($result)) {
- array_push(
- $response, array (
- 'edited_by'=>$row['edited_by'],
- )
- );
- }
- echo json_encode($response);
- }
- mysqli_close($conn);
- ?>
Add Comment
Please, Sign In to add comment