<?php

//fetch.php
if(isset($_POST["action"]))
{
 //$connect = mysqli_connect("localhost", "root", "", "testing");
 include('includes/config.php');
 $output = '';
 if($_POST["action"] == "vehicle")
 {
  $query = "SELECT * FROM vehicles WHERE vehicle_id = '".$_POST["query"]."'";
  $result = mysqli_query($con, $query);
  $output .= '<option value="">Select RegNo</option>';
  while($row = mysqli_fetch_array($result))
  {
    //$output .= '<option value="">Select Name</option>';
   $output .= '<option value="'.$row["vehicle_id"].'">'.$row["reg_no"].'</option>';
  }
 }

 if($_POST["action"] == "regno")
 {
  $query = "SELECT * FROM vehicles WHERE vehicle_id = '".$_POST["query"]."'";
  $result = mysqli_query($con, $query);
  //$output .= '<option value="">Select Measurement</option>';
  while($row = mysqli_fetch_array($result))
  {
    //$output .= '<option value="">Select Name</option>';
   $output .= '<option value="'.$row["vehicle_id"].'">'.$row["measurement"].'</option>';
  }
 }


 echo $output;
}
?>