<?php
require('dbcon.php');
    $query = "SELECT timeout from timeout_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$timeout = $row['timeout'];
    }
    $query = "select screenwidth from width_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$width = $row['screenwidth'];
    }
    $width = $width . "px";
    //$width = '2000';
?>
<?php
require('dbcon.php');
$output = '';
$query = "SELECT noofrow FROM noofrow_mst WHERE description='noofrow'";
	$rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
	while ($row = mysqli_fetch_assoc($rs)) {
		$noofrow     = $row['noofrow'];
	}
if(isset($_POST["query"])) {
    $search = $_POST["query"];
    $sql = "SELECT * FROM item_mst WHERE Lower(partno) LIKE Lower('%" . $search . "%') or Lower(description_one) LIKE Lower('%" . $search . "%') ORDER BY partno LIMIT $noofrow";
} else {
    $sql = "SELECT * FROM item_mst ORDER BY partno LIMIT $noofrow";
}
$result = mysqli_query($connect, $sql);
if (mysqli_num_rows($result) > 0) {
    $output .= '
    <div class="table-responsive" style="font-size:18px; width: 100%;">
		<table id="tblexportData" class="table table bordered" >
			<tr>
				<th style = "text-align: left">partno</th>
				<th style = "text-align: left">description_one</th>
				<th style = "text-align: right">list</th>
				<th style = "text-align: right">cost</th>
				<th style = "text-align: right">stk_qty</th>
				<th style = "text-align: right">stk_val</th>
				<th style = "text-align: right">moq</th>
				<th style = "text-align: right">boxqty</th>
				<th style = "text-align: left">hsn_code</th>
				<th style = "text-align: left">segment</th>				
			</tr>';
    while ($row = mysqli_fetch_array($result)) {
        $output .= '
			<tr>
				<td style="text-align: left; width:100px;">' . $row["partno"] . '</td>
				<td style="text-align: left; width:400px;">' . $row["description_one"] . '</td>
				<td style="text-align: right; width:100px;">' . number_format($row["list"], 2, '.', ''). '</td>
				<td style="text-align: right; width:100px;">' . number_format($row["cost"], 2, '.', ''). '</td>
				<td style="text-align: right; width:100px;">' . number_format($row["stk_qty"], 2, '.', ''). '</td>
				<td style="text-align: right; width:100px;">' . number_format($row["stk_val"], 2, '.', ''). '</td>
				<td style="text-align: right; width:100px;">' . number_format($row["moq"], 0, '.', ''). '</td>
				<td style="text-align: right; width:100px;">' . number_format($row["boxqty"], 0, '.', ''). '</td>
				<td style="text-align: left; width:100px;">' . $row["hsn_code"] . '</td>
				<td style="text-align: left; width:100px;">' . $row["segment"] . '</td>
			</tr>';
    }
    echo $output;
} else {
    echo 'Data Not Found';
}

?>
