jQuery to connecto to DB and get field and display in Div

jQuery to connecto to DB and get field and display in Div

I have a php select box that is populated from a mysql query. What i require is when an option is selected, i want it to contact the mysql database and get 2 fields, displaying on of them and storing the other is a session object in php. I have searched the web and found this can be done with JSON. What I have so far?

jQuery:
  1. <script language="javascript">
  2. function populateTypeOfCover() {
  3. <?php echo "var TypeOfCoverID = ".$_SESSION["TypeOfCoverID"]; ?>
  4. $.getJSON('/client.add.contract_json.php', {manufacture:$('#typeofcover_field').val()}, function(data) {
  5. alert("yes");
  6. });
  7. }
  8. $(document).ready(function() {
  9. populateTypeOfCover();
  10. $('#typeofcover_field').change(function() {
  11. populateTypeOfCover();
  12. });
  13. });
  14. </script>

PHP client.add.contract_json.php:
  1. <?php
  2. $TypeOfCoverID = $_POST['typeofcover_field'];

  3. $SQL = "SELECT * FROM tbltypeofcover WHERE typeOfCoverID = '$TypeOfCoverID'";
  4. $Result = mysql_query($SQL, $link) or die('Error, query failed<br>'.$SQL);
  5. $Row = mysql_num_rows($Result);
  6. $TypeOfCover = $row['typeOfCover'];
  7. $Cost = $row['Cost'];
  8. $LandlordPackage = $row['landlordPackage'];

  9. $arr = array('input#paymentamount_field' => $Cost);
  10. echo json_encode( $arr );
  11. ?>

I need to display the $Cost in the #paymentamount_field and store the $LandlordPackage to $_SESSION["LandlordPackage "].

This may not be the best way to do this but this is the only way i could find todo it, so happy for other methods to be used maybe ajax?

Also, does the json always need to be stored in its own file? can you not just create a function and put them all together in one php file. If the answer to this is yes, how would you then call it?

Thanks for your help in advance,
D