Problem with PHP, MySQL and JavaScript. How to get the data that I've query?

using PHP and return that data in the value of the input text? for example.

<script>
function getMe(){
var name = document.getElementById('productName');
var price = document.getElementById('price');
var srp = document.getElementById('srp');
var qo = document.getElementById('optimumLevel');
var total = document.getElementById('ta');

<?php
if(!isset($_POST['productCode'])){
$productCode = $_POST['productCode'];
$query = "SELECT * FROM tbl_product
WHERE `productCode` LIKE '%" . '$productCode' . "%' ";
$query2 = mysql_query($query,$web) or die(mysql_error());
$getData = mysql_fetch_assoc($query2);
}
?>

name.value = "<?php echo $getData['productName'];?>";
price.value = "<?php echo $getData['price'];?>";
srp.value = "<?php echo $getData['srp'];?>"
qo.value = "<?php echo $getData['optimumLevel'];?>";
total.value = parseInt(price.value) * parseInt(qo.value);
}
</script>

I've call the function getMe() in the event onchange of the select so that everytime I select different data in the select, the query will be executed. Please Help.
 
Back
Top