
<?php 
 if(file_exists('json_files/json-file.json')){ 
    $json = file_get_contents('json_files/json-file.json');
    //Decode JSON
    $json_data = json_decode($json,true);
    $results = array();
    }
    $i=1;
 
    if($rncnt > 0){
    foreach($data as $result2){    
?>

<tr>
    <td align="center" valign="top"><input class="form-check-input" type="checkbox" value="1" id="TreatChk{{$i}}"
            name="TreatChk{{$i}}" onclick="treatcheck('TreatChk{{$i}}',{{$result2->id}},{{$i}})" checked>
    </td>
    <td>
        <select class="form-control" name="TreatType{{$i}}" id="TreatType{{$i}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatType'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>" <?php if($result2->TreatType1 == $result['Values']){?>
                selected <?php } ?>>
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
    <input type="text" value="<?php echo $result2->TreatName1; ?>" name="TreatName{{$i}}" id="TreatName{{$i}}" class="form-control input-lg"
        oninput="get_drug_name({{$i}})"  style="height:35px;"/>
        <div id="DrugLists{{$i}}">
        </div>
       
    </td>
    <td>
        <select class="form-control" name="TreatDose{{$i}}" id="TreatDose{{$i}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatDose'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>" <?php if($result2->TreatDose1 == $result['Values']){?>
                selected <?php } ?>>
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <select class="form-control" name="TreatFreq{{$i}}" id="TreatFreq{{$i}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatFreq'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>" <?php if($result2->TreatFreq1 == $result['Values']){?>
                selected <?php } ?>>
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <select class="form-control" name="TreatDur{{$i}}" id="TreatDur{{$i}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatDur'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>" <?php if($result2->TreatDur1 == $result['Values']){?>
                selected <?php } ?>>
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <select class="form-control" name="TreatEye{{$i}}" id="TreatEye{{$i}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatEye'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>" <?php if($result2->TreatEye1 == $result['Values']){?>
                selected <?php } ?>>
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
</tr>
<?php $i++;}} 
for($i2=$rncnt+1;$i2<=8;$i2++){
?>
<tr>
    <td align="center" valign="top"><input class="form-check-input" type="checkbox" value="1" id="TreatChk{{$i2}}"
            name="TreatChk{{$i2}}" onclick="treatcheck('TreatChk{{$i2}}',0,{{$i2}})">
    </td>
    <td>
        <select class="form-control" name="TreatType{{$i2}}" id="TreatType{{$i2}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatType'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>">
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <input type="text" value="" name="TreatName{{$i2}}" id="TreatName{{$i2}}" class="form-control input-lg"
        oninput="get_drug_name({{$i2}})" style="height:35px;"/>
        <div id="DrugLists{{$i2}}">
        </div>
        
    </td>
    <td>
        <select class="form-control" name="TreatDose{{$i2}}" id="TreatDose{{$i2}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatDose'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>">
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <select class="form-control" name="TreatFreq{{$i2}}" id="TreatFreq{{$i2}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatFreq'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>">
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <select class="form-control" name="TreatDur{{$i2}}" id="TreatDur{{$i2}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatDur'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>">
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
    <td>
        <select class="form-control" name="TreatEye{{$i2}}" id="TreatEye{{$i2}}" style="height:35px;">

            <option value="" selected>...</option>
            <?php
foreach($json_data['JsonData']['TreatEye'] as $result) {?>
            <option value="<?php echo $result['Values']; ?>">
                {{$result['Values']}}</option>
            <?php } ?>
        </select>

    </td>
</tr>
<?php }  ?>