<?php
ob_start();
error_reporting(E_ALL);
require("includes/check_auth_user.php");

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' valign='top'><input type='text' size='6' maxlength='6' name='srno_$ctr' class='sno form-control' style='height:33px;' value='$mctr'/></td>";
    
    echo "<td align='left'>";
    echo "<input list='item_$ctr' name='item_$ctr'  class='item form-control' style='height:33px;'>";
    echo "<datalist id='item_$ctr'>";
    echo "<option value=''></option>";
    $mitem1 = mysqli_query($conn, "SELECT `name` FROM `item` ORDER BY name") or die(mysqli_error($conn));
    while ($trow1 = mysqli_fetch_array($mitem1)) {
        echo "<option value='$trow1[name]'>";
    }
    echo "</datalist>";
    echo "</td>";
    
    echo "<td align='center' valign='top'>";
    echo "<input type='text' name='location_$ctr'  style='height:34px;' class='location form-control'>";
    echo "</td>";
    echo "<td align='center' valign='top'>"
    . "<input type='text' size='4'  name='qty_$ctr' class='qty form-control'  style='text-align:right;height:33px;' value='0'>"
        . '<input type="text" size="4"  name="maxqty_'.$ctr.'" class="maxqty form-control form"  style="text-align:right;height:33px;" value="0">'
    . "</td>";
    echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>
 