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

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $hide = $_REQUEST["hide"];
    $hide_var = "";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
$mctr++;
    Echo "<tr>";
    Echo "<td><i class='fa fa-close remove' $hide_var></i></td>";
    Echo "<td><input type='text' class='form-control form text-right srno'      name='srno_$ctr'        value='$mctr'></td>";
    Echo "<td>";
    Echo "<select class='form-control form exam fetchpart_$ctr' name='exam_$ctr' style='width:100%'>";
    Echo "<option value=''></option>";
    $getexm = mysqli_query($conn, "SELECT * FROM `exam` order by name")or die(mysqli_error($conn));
    while ($exm = mysqli_fetch_array($getexm)) {
        Echo "<option value='$exm[name]'>$exm[name]</option>";
    }
    Echo "</select>";
    echo "<input type='hidden' name='examname_$ctr' class='examname' value=''>";
    Echo "</td>";
    Echo "<td>";
    Echo "<select class='form-control form subject fetchpart_$ctr' name='subject_$ctr' style='width:100%'>";
    Echo "<option value=''></option>";
    $getsub = mysqli_query($conn, "SELECT * FROM `subject` order by name")or die(mysqli_error($conn));
    while ($sub = mysqli_fetch_array($getsub)) {
        Echo "<option value='$sub[name]'>$sub[name]</option>";
    }
    Echo "</select>";
    echo "<input type='hidden' name='subname_$ctr' class='subname' value=''>";
    Echo "</td>";
    Echo "<td><input type='number' step='any' class='form-control form text-right preliums'     name='preliums_$ctr'       value=''></td>";
    Echo "<td><input type='number' step='any' class='form-control form text-right packrate'     name='packrate_$ctr'       value=''></td>";
    Echo "</tr>";
    $ctr++;
    
} else {
    echo "ERROR";
}
?>
 