Hey Guys. I am using the jQuery ajax function to send data from a form and return some results.
function get(){
$.post('data.php', { name: $('#name').attr('value'),lname: $('#lname').attr('value') },
function (data){
$('#age').html(data).show();
});
}
The function posts to data.php.
$name = $_POST['name'];
$lname = $_POST['lname'];
//DB connect
mysql_connect('localhost', 'root', 'password')
or die("Could not connect: " . mysql_error());
//DB select
mysql_select_db("users")
or die("Could not find database: " . mysql_error());
$sql="SELECT * FROM users WHERE name='$name'";
$result=mysql_query($sql)or die(mysql_error());
$row = mysql_fetch_array($result);
$return_name =$row['name']; //set the session for the user login
$return_lname =$row['lname'];
$return_age =$row['age'];
echo $return_name;
echo $return_lname;
echo $return_age;
The output is all displayed in the #age div but i want to be able to specify each of the three outputs to a different div?
Thanks guys.