I need to fill all matching records in a table after inserting id in textbox. But currently I am getting only one record.
php
<?php
$id=$_POST['userID'];
$db_host = 'jo\SQL2005';
$db_username = 'jo';
$db_password = '123321';
$db_name = 'db_test2';
mssql_connect($db_host, $db_username, $db_password);
mssql_select_db($db_name);
$query=mssql_query("select * from address where user_id='$id'");
$result=mssql_fetch_assoc($query);
$json= array('id'=>$result['id'],'user_id'=>$result['user_id'],
'street'=>$result['street'],
'quarter'=>$result['quarter'],'Phone_number'=>$result['Phone_number']);
echo json_encode($json);
exit;
?>
javaScript
function getname()
{
var id=$("#userID").val(); // get the id from textbox
$.ajax({
type:"post",
dataType:"json",
data:"userID="+id,
url:"address_json_data.php",
success:function(json)
{
$("table.imagetable").
append("<tr><td>" + json.user_id + "</td><td>" +
json.street + "</td></tr>");
}
});
}
html
<input name="userID" id="userID" onChange="getname()" type="text" />
<table border='1'class="imagetable">
<tr><th>id</th><th>email</th></tr>
</table>
Any Help Very Thanks