Thanks a lot first of all!! 🙂
Ok I heard everything you said and I fixed up my code a little bit..
For the injections I'll worry about them later on
the main.php is now:
<html>
<head>
<?php
ini_set('display_errors', 1 );
error_reporting(E_ALL);
?>
<script type="text/javascript" src="../JQuery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#Client_ID').live('change', function(event) {
$.ajax({
url : 'getData.php',
type : 'POST',
dataType: 'json',
data : $('#myform').serialize(),
success: function( data ) {
$("#address1").val( data["address1"] );
$("#address2").val( data["address2"] );
}
});
});
});
</script>
</head>
<body>
<form id='myform' method='post'>
<select name='Client_ID' id='Client_ID'>
<option value=''>Select</option>
<option value='Roy'>Roy</option>
<option value='Ralph'>Ralph</option>
</select>
<div name='address1' id='address1'>
<div name='address2' id='address2'>
</form>
</body>
</html>
and the getData.php
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
include('../content/Conx.php');
$clientId = $_POST['Client_ID'];
$db = "projet";
$query = "SELECT nom, prenom FROM client WHERE nom = '$clientId' ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$add1 = $row["nom"];
$add2 = $row["prenom"];
$arr = array( 'address1' => $add1, 'address2' => $add2);
echo json_encode( $arr );
?>
I learned some couple of basic things in debugging and finally used the firebug to know what it displaying
In firebug it says that it displays
{"address1":"Roy","address2":"Maroun"}
Which is 100% correct..
But it wont show up in the main.php ...