<?php

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

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

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $mctr = $ctr;
    $mctr++;

    echo "<tr>";
    echo "<td align='left'><input type='text' size='6' maxlength='6' maxlength='6' name='srno_$ctr' class='sno form-control form' value='$mctr' style='height:33px;'/></td>";
    echo "<td align='left'>";
    echo "<select name='access_$ctr' style='height:34px;' class='form-control form'>";
    echo "<option value=''></option>";
    $getaccess = mysqli_query($conn, "SELECT `code`, `name` FROM `access` ORDER BY `name`") or die(mysqli_error($conn));
    while ($wacc = mysqli_fetch_array($getaccess)) {
        echo "<option value='$wacc[code]' >$wacc[name]</option>";
    }
    echo "</select>";
    echo "</td>";
    echo "<td align='center' valign='top'><input type='text' name='qty_$ctr' class='qty form-control form' value='' style='text-align:right;height:33px;'/></td>";
    echo "<td align='center' valign='top'><input type='text' name='unit_$ctr' class='unit form-control form' value='' style='text-align:left;height:33px;'/></td>";
    echo"</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 