I am doing a basic inventory system I was trying to edit and update record by clicking on edit button which pass the id to the process file through the url, there I pic the id and I was able to change and update the data, now the problem is the product category, before it was appearing in just a text box and I have to type the new product to replace the old one but this could make spelling or other mistakes, to avoid that I am trying to have drop down list which is loading products from database and I will choose the new one to replace but it's not working, process file picking the id from html file and query I have checked also it's working fine but data is not being updated.
<html>
<form name="form" action="edit_record.php" method="POST" enctype="multipart/form-data">
<select name="pro_update" class="formTxtInputmany">
Product Name: <option>SELECT PRODUCT</option>
<?php
$sql = "SELECT pro_id,pro_name FROM products ORDER BY pro_name ASC";
$query = $conn->query($sql);
$result = $query->fetchAll(PDO::FETCH_ASSOC);
$arrlength = count($result);
for ($x = 0; $x < $arrlength; $x++){?>
<option value="<?php echo $result[$x]['pro_id'].','.$result[$x]['pro_name']; ?>">
<?php echo $result[$x]['pro_name']; ?>
</option><?php
} ?>
</select>
<input type="submit" value="UPDATE THE RECORD">
</form>
</html>
// process file
<?php
if(isset($_POST['pro_update'])){
$pro_update = $_POST['pro_update'];
if ($pro_update == "SELECT PRODUCT"){
echo "please choose producct";
}else{
$values = explode(',', $pro_update);
$pro_id = (int)$values[0];
$pro_update = $values[1];
$updateQuery = "UPDATE products SET pro_name = $pro_update
WHERE pro_id = $pro_id";
$query = $conn->prepare($updateQuery);
$query->execute(array($pro_update));
}
}