Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p>Enter the value:</p>
- <form action="" method="post" >
- <input type="text" id="customerAutocomplete" autocomplete="off" name="">
- </form>
- <div style="background-color: pink;" id="result"></div>
- <script type="text/javascript" language="JavaScript">
- $(document).ready(function($){
- $('#customerAutocomplete').autocomplete({
- source:'scratch2.php',
- minLength:1,
- select:function(event,ui){
- var code=ui.item.id;
- if (code != '') {
- location.href = '/newTDMH/production/scratch3.php?id='+code;
- }
- }
- });
- });
- </script>
- <?php
- $server = 'localhost';
- $user = 'root';
- $password = '';
- $database = 'tdmh';
- $mysqli = new MySQLi($server,$user,$password,$database);
- $term = trim(strip_tags($_GET['term']));
- $a_json = array();
- $a_json_row = array();
- 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 ")){
- while($row = mysqli_fetch_array($data)){
- $patientId = htmlentities(stripcslashes($row['PatientID']));
- $firstName = htmlentities(stripcslashes($row['FName']));
- $middleName = htmlentities(stripcslashes($row['MName']));
- $lastName = htmlentities(stripcslashes($row['LName']));
- $a_json_row["id"] = $patientId;
- $a_json_row["value"] = $firstName.' '.$middleName.' '.$lastName;
- $a_json_row["label"] = $firstName.' '.$middleName.' '.$lastName;
- array_push($a_json, $a_json_row,"hello");
- }
- }
- echo json_encode($a_json);
- flush();
- $mysqli->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement