<?php
include "include/db.php";
include "include/auth.php";

if(isset($_REQUEST["maps_uom_id"]) && isset($_REQUEST["maps_id"])){
    $maps_uom_id = $_REQUEST["maps_uom_id"];
    $maps_id = $_REQUEST["maps_id"];
    
if(!empty($maps_uom_id)) {
  $query = "SELECT * FROM uom_field WHERE uom_id = $maps_uom_id AND uom_field_type = 'maps'";
  $run = mysqli_query($conn, $query);
?>
<?php
  foreach($run as $uom_field) {
?>
<label for="<?php echo $uom_field['uom_field_name']?>"><?php echo $uom_field['uom_field_title']?></label>
<?php 

 $uom_field_id = $uom_field['uom_field_id'];
if(empty($maps_id)){
    $uom_field_value = '';
}else{
    $query1 = "SELECT * FROM maps_uom_value WHERE maps_id = $maps_id AND uom_field_id = $uom_field_id";
    $run1 = mysqli_query($conn, $query1);
    $row = mysqli_fetch_array($run1);
    $uom_field_value = $row['maps_uom_value_amount'];

}?>
  <input type='text' class='form-control' name='<?php echo $uom_field['uom_field_name']?>' id='<?php echo $uom_field['uom_field_name']?>' value='<?php echo $uom_field_value; ?>' >

<?php
  }
}

    }
?>