ajax retrieve mysql data

Splaze

New Member
I am trying to input name and phone in form and get data from mysql based on input values. When I run query by on click function the browser displays my php and query but instead of values from database it displays 'object HTMLInputElement'.I must be missing something in my script but can't figure out what it is.Can anybody tell me when I submit this ajax/mysql why the value is not being displayed. See code below and hanks for your help...HTML and SCRIPT\[code\]<script type="text/javascript" src="http://stackoverflow.com/questions/14085497/jquery-1.8.3.min.js"></script><script language="javascript" type="text/javascript">function ajaxFunction(){var ajaxRequest; try{ ajaxRequest = new XMLHttpRequest();} catch (e){ try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Your browser broke!"); return false; } }}ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; }}var age = document.getElementById('lname').value;var queryString = "?lname=" + lname + "&phone=" + phone ;ajaxRequest.open("GET", "find.php" + queryString, true);ajaxRequest.send(null); }</script><form name='myForm'>Last Name: <input type='text' id='lname' />Phone: <input type='text' id='phone' /><input type='button' onclick='ajaxFunction()' value='http://stackoverflow.com/questions/14085497/Query MySQL' /></form><div id='ajaxDiv'>Your result will display here</div></body></html>\[/code\]PHP\[code\]$inputedname = $_GET['lname'];$inputedphone = $_GET['phone'];$inputedname = mysql_real_escape_string($inputedname);$inputedphone = mysql_real_escape_string($inputedphone);$query = "SELECT FirstName, Phone FROM ClientInfo WHERE LastName = '$inputedname' AND Phone = '$inputedphone'";$qry_result = mysql_query($query) or die(mysql_error());$display_string = "<table>";$display_string .= "<tr>";$display_string .= "<th>Name</th>";$display_string .= "<th>Phone</th>";$display_string .= "</tr>";while($row = mysql_fetch_array($qry_result)){$display_string .= "<tr>";$display_string .= "<td>$row[FirstName]</td>";$display_string .= "<td>$row[Phone]</td>";$display_string .= "</tr>";}echo "Query: " . $query . "<br />";$display_string .= "</table>";echo $display_string;\[/code\]In Browser
JMN7U.png
 
Back
Top