Guest User

Untitled

a guest
Mar 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <select value="center_name" ng-model="selectedname" ng-options="name.center_name for name in namelist" ng-change="loadcounsellors(selectedname)">
  2. <option >Please select a name</option>
  3. </select>
  4.  
  5. var app=angular.module('myapp',[]);
  6. app.controller('MyCtrl',function($scope,$http,$httpParamSerializer)
  7. {
  8. $http.get("logintype.php")
  9. .then(function(response)
  10. {
  11. $scope.namelist=response.data;
  12.  
  13. })
  14. $scope.loadcounsellors=function(item){
  15. alert(item.center_name);
  16. $http.post("counselorlist.php",$httpParamSerializer({center_name:item.center_name}))
  17.  
  18. .then(function(response)
  19. {
  20. // alert("hello world");
  21. $scope.counsellor=response.data;
  22. alert(response.data);
  23.  
  24. })
  25. }
  26. })
  27.  
  28. <h2>Selected: {{counsellor}}</h2>
  29.  
  30. <?php
  31.  
  32. require "connection.php";
  33. // $postdata = file_get_contents("php://input");
  34. // $params = json_decode(file_get_contents('php://input'), true);
  35. // $request1 = json_decode($postdata);
  36. // echo $request1;
  37. $center_name = $_POST['center_name'];
  38. echo $center_name;
  39. // $center_name = "Andheri"; //This works fine.
  40. $query = "select distinct(edited_by) from telephonic_enquiry
  41. where center_name='$center_name'";
  42. $result = mysqli_query($conn, $query);
  43. if (mysqli_num_rows($result)>0 ) {
  44. $response=array();
  45. while ($row= mysqli_fetch_array($result)) {
  46. array_push(
  47. $response, array (
  48. 'edited_by'=>$row['edited_by'],
  49. )
  50. );
  51. }
  52. echo json_encode($response);
  53. }
  54. mysqli_close($conn);
  55. ?>
Add Comment
Please, Sign In to add comment