<?php
$mysqli = new mysqli();
$text = $mysqli->real_escape_string($_GET['term']);
$query = "SELECT * FROM products WHERE productcodes LIKE '%$text%' ORDER BY productcodes ASC";
$result = $mysqli->query($query);
while($row = $result->fetch_assoc())
{
?>
<script>
$("input[type='text'][name='quantity']").keyup(function () {
var value = $(this).val('<?php echo $row['qty']?>');
}).keyup();
$("input[type='text'][name='ponumber']").keyup(function () {
var value = $(this).val('<?php echo $row['ponumber'] ?> ');
}).keyup();
</script>
<?php
}
?>
This is with JQUERY it is the simplest solution i can come up with, it targets the INPUT fields with the relevant name that you have used and fills it in from the results returned on the search. You may want to limit results to 1 on the mysql query,
$row[''] <--- inside here you need to call the correct fiield name, not sure what you called them in your database, i just guessed
But this should help you understand how to fill it in live?
see it working here in theory http://jsfiddle.net/hdhJw/