<?php
require('../config/dbcon.php');
$output = '';
if (isset($_POST["query"])) {

	$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'];
	}

	$search = mysqli_escape_string($connect, $_POST["query"]);
	$query = "SELECT * FROM segment_mst WHERE Lower(segment_name) LIKE Lower('%" . $search . "%') limit $noofrow";
} else {

	$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'];
	}
	$query = "SELECT * FROM segment_mst ORDER BY segment_name limit $noofrow";
}

$result = mysqli_query($connect, $query);
if (mysqli_num_rows($result) > 0) {
	$output .= '
	<div class="table-responsive" style="width: 50.6%; height: 380px;">
		<table id="tblexportData" class="table table bordered" >
			<tr>
				<!--th width="50px" style=" text-align: center">Edit</th>
				<th width="50px" style=" text-align: center">Delete</th-->
				<th style = "width:400px; text-align: left">segment_name</th>
			</tr>';
	while ($row = mysqli_fetch_array($result)) {
		$output .= '
			<tr>
				<!--td style="text-align: center"><button type="button" name="update" id="' . $row["id"] . '" class="update btn btn-success btn-xs">Edit</button></td>  
				<td style="text-align: center"><button type="button" name="delete" id="' . $row["id"] . '" class="delete btn btn-danger btn-xs">Delete</button></td-->
				<td style="text-align: left">' . $row["segment_name"] . '</td>
			</tr>
		';
	}
	echo $output;
} else {
	echo 'Data Not Found';
}
