i want to retrieve 3 information from the database based on the ID
number input. when i type number 5 in an <input id="id">
html markup. get the name
, age
, email
of the associated number and insert it on a dedicate <input>
box for each result
how do i get the multiple result from my query and then input the result on my <input>
markup
<input id="name"> //insert name from db
<input id="age"> //insert name from db
<input id="email"> //insert name from db
below is my code, where it only fetches the name
from the database and input it on an <input id="name">
markup.
My Jquery
var id = $('input#id').val(); //get value of input box
$.post('./ajax/getdata.php', {id: id}, function(data) //pass this to getdata.php
{
$('input#name').val(data);
}
MY getdata.php
if (isset($_POST['id']) === true && empty($_POST['id']) === false)
{
require '../connect.php';
$query = "SELECT * FROM `members` WHERE `memberNo` = '" . mysql_real_escape_string(trim($_POST['id'])). "' ";
$result = $db->query($query);
while ($row = $result->fetch_assoc())
{
echo $row['firstname'];
}
}