<?php
include("db.php");
 $counterCurrency=$_POST['cCurrency'];
 $baseCurrency=$_POST['bCurrency'];  

$checkRate_sql="select * from crrencyrate where  counterCurrency='$counterCurrency' and baseCurrency='$baseCurrency' order by id desc limit 1";

$checkRate_query = $db->query($checkRate_sql);
$checkRate_Row=$checkRate_query ->fetch_array();
$checkRate=$checkRate_Row['rate'];
$unit=$checkRate_Row['unit'];

$first=$checkRate;
$second=$unit;

 if(isset($checkRate)){
   
  echo "<input  type='hidden' class='form-control' id='mixData'         name='currencyPriec'  value=".$first."/".$second.">";
  echo "<input  type='text'   class='filed' id='rate_mixData'    name='rate_currencyPriec'  value=".$first.">";
  echo "<input  type='hidden'  name='mode'   id='mode'      value='mode_1'>";
 }
//===============================================================================
if(!isset($checkRate)){
 
$checkRate1_sql="select * from crrencyrate where  counterCurrency='$baseCurrency' and baseCurrency='$counterCurrency' order by id desc limit 1";
$checkRate1_query= $db ->query($checkRate1_sql);
$checkRate1_Row=$checkRate1_query ->fetch_array();
$unit1=$checkRate1_Row['unit'];
 
$checkRate1=$checkRate1_Row['rate'];
 
 $first=$unit1;
//$second=$checkRate1;
 
 $second=$checkRate1;
 
     //echo $result=$unit1/$checkRate1;
echo "<input  type='hidden'    id='mixData'        name='currencyPriec'  value=".$first."/".$second.">";
echo "<input  type='text'      class='filed' id='rate_mixData'   name='rate_currencyPriec'  value=".$second.">";
echo "<input  type='hidden'   name='mode'  id='mode'      value='mode_2'>";
}


    //echo "<input  type='hidden' class='form-control'  name='second' value='$second'>";   
   






?>