<?php
$data = array();

$stock_id = $_GET['stock_id'];

//$mysqli = new mysqli("localhost","vps10082_inspect","kw8!boB#C}_d","vps10082_oliacInspections");
$mysqli = new mysqli("localhost","vps10082_inspect","kw8!boB#C}_d","vps10082_oliacInspections");
if ($mysqli -> connect_errno) {

  echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  exit();

}else{

$getExtRecord = "SELECT ext.*, exterior_grade_desc.descr FROM
exterior_auction_grade AS ext
INNER JOIN exterior_grade_desc ON ext.grade = exterior_grade_desc.id WHERE stock_id='$stock_id'";

$getInteRecord = "SELECT inte.*, interior_grade_desc.descr FROM
interior_auction_grade AS inte
INNER JOIN interior_grade_desc ON inte.grade = interior_grade_desc.id WHERE stock_id='$stock_id'";
 
$getExtRecord = $mysqli->query($getExtRecord);
$getIntRecord = $mysqli->query($getInteRecord);
$ExtRow =  mysqli_fetch_array($getExtRecord);
$intRow =  mysqli_fetch_array($getIntRecord);
 
if($ExtRow   AND $intRow){

      $data = array('ExtID' =>$ExtRow['grade'],
      'ExtDescr' =>$ExtRow['descr'],
      'IntID' =>$intRow['grade'],
      'IntDescr' =>$intRow['descr'],
      'hideView' => 'Yes');

      echo json_encode($data);
  }else{
    echo null;
  }

}

?>
