<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$array = '';
$zroot = $_SESSION['zdbroot'];
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn,$zdb);

 
if (isset($_REQUEST['sval'])) {
    $sval = $_REQUEST['sval'];
    $soval = $_REQUEST['soval'];
    if ($soval == "1") {

        $result = mysqli_query($conn,"SELECT `mm` FROM `$zroot`.`metric` WHERE fractinch ='$sval' limit 0,1") or die(mysqli_error($conn));
        $get = mysqli_fetch_array($result);
        if ($get == '') {
            echo $sval;
        } else {
            echo $get["mm"];
        }
    } else if ($soval == "2") {
        $result = mysqli_query($conn,"SELECT `mm` FROM `$zroot`.`nbmetric` WHERE nbinch ='$sval' limit 0,1") or die(mysqli_error($conn));
        $get = mysqli_fetch_array($result);
        if ($get == '') {
            echo $sval;
        } else {
            echo $get["mm"];
        }
    } else if ($soval == "3") {
        echo $sval;
    }
}
?>