maxudaskin Posted August 16, 2010 Share Posted August 16, 2010 Hi Guys! I'm working on a website feature that will grab information about a selected airport from a MySQL database. The information will be grabbed and displayed, assuming that the airport identification is correct, to the screen, although I am having some troubles here. The code is below. Excerpt from front end <div class="contentBox cb_blue mar_bottom"> <input type="text" name="departure" id="departure" style="width:350px;" onChange="loadAirportInfo('departureInfo', 'this.value')" value="<?= @$_POST['departure']; ?>"> <div id="departureInfo"></div> </div> loadAirportInfo code function loadAirportInfo(elemId, ident) { 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 (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(elemId).innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","include/lib/ajaxAddInfo.php?get=airportInfo&airport="+ident,true); xmlhttp.send(); } ajaxAddInfo.php code <?php if($_GET['get'] == 'airportInfo') { $sql = 'SELECT * FROM `geo_airports` WHERE `ident` = \'' . $_GET['ident'] . '\''; $query = mysql_query($sql); if(mysql_num_rows($query) < 1) { return ''; } else { $result = mysql_fetch_array($query); return 'Identification: ' . $result['ident'] . '<br />' . 'Airport Name: ' . $result['name'] . '<br />' . 'Municipality: ' . $result['municipality'] . '<br />' . 'Country: ' . $result['country'] . '<br />'; } } ?> Now, I am sure that the issue is with the AJAX and not the PHP or regular Javascript. Thank you for your help and opinions in advance. Max Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted August 16, 2010 Author Share Posted August 16, 2010 Here is a cap of a few rows of the database, even though, it won't help much. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted August 16, 2010 Author Share Posted August 16, 2010 The issue was, I was returning the value, not echoing it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.