<?php
if(isset($_POST["actionv"]))
{
    include('includes/config.php');
    $output = '';
    
    if($_POST["actionv"] == "vendor")
    {
        $vendors = $_POST["query"];
        $query = "SELECT * FROM `measurements` as m  WHERE m.vendor_id = '".$vendors."' AND m.md_status='0' ";
        $result = mysqli_query($con, $query);
        $output .= '<option value="">Select Vehicle</option>';
        while($row = mysqli_fetch_array($result))
        {
            $output .= '<option value="'.$row["vehicle_id"].'">'.$row["vehicle_id"].'</option>';
        }
    }
    elseif ($_POST["actionv"] == "vehicle")
    {
        $vendors = $_POST["vendor"];
        $query = "SELECT DISTINCT vmeasurement FROM `measurements` as m 
                  WHERE m.vendor_id='".$vendors."' AND m.vehicle_id = '".$_POST["query"]."'  AND m.md_status='0'";
        $result = mysqli_query($con, $query);
       // $output .= '<option value="">Select Measurement</option>';
        while($row = mysqli_fetch_array($result))
        {
            $output .= '<option value="'.$row["vmeasurement"].'">'.$row["vmeasurement"].'</option>';
        }
    }
    
    echo $output;
}
?>
