Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="text" name="flightnumber" id="flightnumber" onpointermove="showUser(this.value)" style="width: 70px;" maxlength="4">
- <input type="text" name="dep" id="dep" style="width: 70px;">
- <input type="text" name="arr" id="arr" style="width: 70px;">
- <script>
- function showUser(str) {
- if (str.length=="") {
- document.getElementById("dep").innerHTML="";
- document.getElementById("arr").innerHTML="";
- return;
- }
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else { // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (this.readyState==4 && this.status==200) {
- var myObj = JSON.parse(this.responseText);
- document.getElementById("arr").innerHTML = myObj.dep;
- document.getElementById("dep").innerHTML= myObj.arr;
- }
- }
- xmlhttp.open("GET","getdata.php?q=" + str,true);
- xmlhttp.send();
- </script>
- <?php
- //look up the record based on email and get the firstname and lastname
- $host_name = 'db5000091260.hosting-data.io';
- $database = 'dbs85930';
- $user_name = 'dbu68420';
- $password = '';
- $connect = mysqli_connect($host_name, $user_name, $password, $database);
- $q = $_GET['q'];
- $myObj->dep = "";
- $myObj->arr = "";
- $sql = "SELECT dep, arr FROM flights WHERE flightnumber = {$q}";
- $result = mysqli_query($connect, $sql);
- if (mysqli_num_rows($result) > 0) {
- while($row = mysqli_fetch_assoc($result)) {
- $myObj->dep = $row['dep'];;
- $myObj->arr = $row['arr'];
- $myJSON = json_encode($myObj);
- echo $myJSON;
- }
- } else {
- echo "0 results";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement