<?php
session_start();
ob_start();
 include "dbPDO.php";
 if(isset($_POST["supp_id"])){
    $cont_idd = $_POST["cont_id"];
    $supp_id = $_POST["supp_id"];
      $output = '';
      $sql =$db->prepare("SELECT cont_id , concat(contract_code,' ', ask_date)  as contt , ask_date
                        from supp_contracts where supp_id = ? order by ask_date desc ");
    $sql->bindParam(1,$supp_id);
    $sql->execute();
     if($sql->rowCount()>0)
       {
             while($row = $sql->fetch()){
                $cont_id   = $row["cont_id"];
                $contt     = $row["contt"];
        if($cont_id == $cont_idd){$output.= "<option selected value= $cont_id >$contt</option>" ;}
              else{ $output .="<option value= $cont_id>$contt</option>";}
            }
        echo $output;
      }
    }
  ?>
