I am developing this where I enter enter the name of the product and the details would display in other input fields. I am able to use jquery autocomplete select the product name.
Below is my code. Please what is really wrong with my code since it works once and stop.
My HTML
<label for="inputEmail3" class="col-sm-2 control-label">Product Name</label>
<div class="col-sm-4 ui-widget">
<input type="text" class="form-control" placeholder="Name of Product" name="search_prod_name" id="search_prod_name">
<div id="product_List">
</div>
</div>
JQUERY
<script>
$(document).ready(function(){
$('#search_prod_name').change(function() {
var prodd_name = $(this).val();
$.ajax({
url:"select_for_sell.php",
method: "POST",
data:{prodd_name: prodd_name},
dataType: "JSON",
success:function(data) {
$('#pro_cat').val(data.pro_cat);
$('#product_name').val(data.product_name);
$('#manu_name').val(data.manu_name);
$('#supp_name').val(data.supp_name);
$('#unit_sell_price').val(data.unit_sell_price);
$('#manu_dt').val(data.manu_dt);
$('#expiry_dt').val(data.expiry_dt);
$('#qty_in_stock').val(data.qty);
}
});
});
});
</script>
My PHP
<?php
include_once('conn/conn.php');
if(isset($_POST["prodd_name"])) {
$query_product = "SELECT * FROM sellnsell_products WHERE product_name = '". $_POST["prodd_name"]."' ";
$result_product = mysqli_query($cnn, $query_product);
while($rrow = mysqli_fetch_array($result_product)) {
$data["pro_cat"] = $rrow["product_cat"];
$data["product_name"] = $rrow["product_name"];
$data["manu_name"] = $rrow["manu_name"];
$data["supp_name"] = $rrow["supp_name"];
$data["unit_sell_price"] = $rrow["unit_sell_price"];
$data["qty_in_stock"] = $rrow["qty"];
$data["manu_dt"] = $rrow["manu_dt"];
$data["expiry_dt"] = $rrow["expiry_dt"];
}
echo json_encode($data);
}
?>