<?php
    include('config.php');
	$limit = 10;	
	$targetpage = "record.php"; 	//your file name  (the name of this file)
	$page = $_POST['page'];
	if($page) 
		$start = ($page - 1) * $limit; 			//first item to display on this page
	else
		$start = 0;								//if no page var is given, set start to 0



	
 	$q = $conn->real_escape_string($_POST['q']);
	$f1 = $_POST['f1'];
	


   	$query_string = " FROM mst_partclass  WHERE pc_name LIKE '%$q%' $query_f1";
   	$order_by = " ORDER BY pc_name";
   
   
   	$sum_sql = "SELECT COUNT(*) as num $query_string";
	$conn_sum_sql = $conn->query($sum_sql);
	$pagenum = $conn_sum_sql->fetch_assoc();
	$total_pages = $pagenum["num"];
   
  	include ("../../sys/paging.php");
 
   	$sql = "SELECT * $query_string $order_by LIMIT $start,$limit";
	$sql_con = $conn->query($sql) or die($sql);

?>

<div class="rec_wrapper">
    <table class="table-striped table-hover table-bordered table table-condensed">
    <thead>
    	<tr class="bold">
            <td>Nama  Kategori</td>
            <td class="tc" style="width:100px;">Action</td>
        </tr>
        </thead>

		<tbody>
        <?php
		$i = 0;
			while($rs = $sql_con->fetch_assoc()){

			$id = $rs['pc_autoid']	;
		?>
        <tr class="rec_body">
            <td><?php echo $rs['pc_name']?></td>
            <td class="tc">
            	<a href="edit?id=<?php echo $id?>"  data-toggle="tooltip" title="Edit Produk">
                <img src="../../image/edit.png" title="Edit Kategori" class="icon"/></a>
                <a href="delete?id=<?php echo $id?>">
                <img src="../../image/delete.png" title="Hapus Kategori" class="icon"/>
                </a>
            </td>         
        </tr>
	<?php 
	$i = $i + 1;
	} 
	if($i==0){
		?>
        <tr class="rec_body">
        	<td colspan="10" style="height:400px;" class="tc"><h4>Belum Ada Data Produk</h4></td>       
        </tr>
	<?php	} ?>
	</tbody>
    </table>
    </div>
    <div class="record_footer">
            <table class="tbl">
        	<tr class="pad5">
            	<td colspan="5" class="tl pad5" style="border:none"><?php echo $pagination?></td>
                <td colspan="4" class="tr pad5 bold" style="border:none;color:#333">Jumlah <?php echo $total_pages?> <?php echo $pageid?></td>
            </tr>
        </table>
    </div>
