<?php

$tableName=$_REQUEST['table_name'];
$columnsQuery = "SHOW COLUMNS FROM " . $tableName;
$columnsResult = mysqli_query($conn, $columnsQuery);
$column_count=mysqli_num_rows($columnsResult);

$tn=str_ireplace(["_"], [' '], $tableName);
?>
<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-12">
                <h1 class="m-0">Table : <?=ucwords($tn);?></h1>
            </div>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container-fluid -->
</div>
<section class="content">
  <div class="container-fluid">
    <div class="row">
      <div class="col-lg-12">
	  <span id="rec_info_msg" style="font-weight: bold;"></span>
        <div class="card">
          <div class="card-body">  
              <div class="table-responsive">
                <table id="example1" class="table table-bordered table-striped">
                  <thead>
                    <tr>
                      <th>Column</th>
                      <th>Type</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?
						while ($column = mysqli_fetch_assoc($columnsResult)) {
					?>
                    <tr>
                      <td nowrap><?php echo $column["Field"];?></td>
                      <td nowrap><?php echo $column["Type"];?></td>
                    </tr> 
					<? } ?>
                  </tbody>
                </table>
              </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<script type="text/javascript">
$(function () {
  $(document).ready(function() {
   var dataTable = $('#example1').DataTable({
      paging: true,      
      lengthChange: true, 
      info: true,        
      ordering: false,
	  pageLength: 100	
    });
	
	var a=$("#example1_info").text();
	$('#rec_info_msg').text(a);
	
	dataTable.on('draw', function() {
        var b=$("#example1_info").text();
		$('#rec_info_msg').text(b);
    });
  });
});
</script>