Advertisement
Guest User

Untitled

a guest
Dec 30th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <p>Enter the value:</p>
  2. <form action="" method="post" >
  3. <input type="text" id="customerAutocomplete" autocomplete="off" name="">
  4. </form>
  5. <div style="background-color: pink;" id="result"></div>
  6.  
  7. <script type="text/javascript" language="JavaScript">
  8. $(document).ready(function($){
  9. $('#customerAutocomplete').autocomplete({
  10. source:'scratch2.php',
  11. minLength:1,
  12. select:function(event,ui){
  13. var code=ui.item.id;
  14. if (code != '') {
  15. location.href = '/newTDMH/production/scratch3.php?id='+code;
  16. }
  17. }
  18. });
  19. });
  20.  
  21. </script>
  22.  
  23. <?php
  24. $server = 'localhost';
  25. $user = 'root';
  26. $password = '';
  27. $database = 'tdmh';
  28.  
  29. $mysqli = new MySQLi($server,$user,$password,$database);
  30.  
  31. $term = trim(strip_tags($_GET['term']));
  32. $a_json = array();
  33. $a_json_row = array();
  34.  
  35. if($data = $mysqli->query("SELECT * FROM patient WHERE PatientID LIKE '%$term%' OR FName LIKE '%$term%' OR MName LIKE '%$term%' OR LName LIKE '%$term%' ORDER BY LName ")){
  36. while($row = mysqli_fetch_array($data)){
  37.  
  38.  
  39. $patientId = htmlentities(stripcslashes($row['PatientID']));
  40. $firstName = htmlentities(stripcslashes($row['FName']));
  41. $middleName = htmlentities(stripcslashes($row['MName']));
  42. $lastName = htmlentities(stripcslashes($row['LName']));
  43.  
  44. $a_json_row["id"] = $patientId;
  45. $a_json_row["value"] = $firstName.' '.$middleName.' '.$lastName;
  46. $a_json_row["label"] = $firstName.' '.$middleName.' '.$lastName;
  47. array_push($a_json, $a_json_row,"hello");
  48. }
  49. }
  50.  
  51. echo json_encode($a_json);
  52. flush();
  53.  
  54. $mysqli->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement