I am looking at using the variable from a SELECT on my form to populate the WHERE clause in my SQL to then populate an INPUT.
This is the getdata.php file
<?php
include "db.php";
$boilermodel = $_POST["boilermodel"];
$sql = "SELECT SAP2009AnnualEfficiency FROM blr.BoilerModel WHERE BoilerModel = '".$boilermodel."' ";
$res = odbc_exec($cnn, $sql);
while($row = odbc_fetch_array($res)) {
echo $row['SAP2009AnnualEfficiency'];
}
?>
This below is the jQuery to pull it onto the INPUT box
<script type="text/javascript">
$(document).ready(function(){
$("select#boilermodel").change(function(){
var boilermodel = $("select#boilermodel option:selected").attr('value');
$.post("assets/configs/getdata.php", {boilermodel:boilermodel}, function(data){
$("input[name='saprating']").html(data);
});
});
});
</script>
When the variable is inserted into the query nothing is returned,no errors show either. I even changed the line in my jQuery from $("input[name='saprating']").html(data);
to $("input#saprating").html(data);
this didn't do anything. A question I do have is that how can I be sure that my $_POST is being fed into the sql?
My main question is where have I gone astray with this so far?