<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        $("#theList tr:even").addClass("stripe1");
        $("#theList tr:odd").addClass("stripe2");

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });	
});

</script>
<?php
include '../../inc/inc.koneksi.php';

$cari	= $_GET['cari'];
$hal	= $_GET['hal'] ? $_GET['hal'] : 0;
$lim	= 15;
	if (!empty($cari)){
		$query2	= "SELECT * FROM st_group WHERE (nama_gr LIKE '%$cari%' OR kategori LIKE '%$cari%' )  ";
	}
	else{
		$query2	= "SELECT * FROM st_group";
	}
	$data2	= mysql_query($query2);
	$jml	= mysql_num_rows($data2);
	
	$max	= ceil($jml/$lim);

echo "<table id='theList' width='100%'>
		<tr>
			<th width='2%'>No.</th>
			<th>Kode</th>
			<th>Nama Kelompok</th>
			<th>Kategori</th>
		</tr>";
	if (!empty($cari)){
		$sql	= "SELECT * FROM st_group WHERE (nama_gr LIKE '%$cari%' OR kategori LIKE '%$cari%' )
					ORDER by kode_gr LIMIT $hal,$lim";		
	}

	else{
		$sql	= "SELECT * FROM st_group ORDER by kode_gr LIMIT $hal,$lim";
	}
		$query = mysql_query($sql);
		
		$no=1+$hal;
		while($r_data=mysql_fetch_array($query)){
			echo "<tr>
					<td align='center'>$no</td>
					<td align='center'>$r_data[kode_gr]</td>
					<td>$r_data[nama_gr]</td>
					<td>$r_data[kategori]</td>					
				</tr>";
			$no++;
		}
		
	echo "</table>";
	echo "<table width='100%'>
		<tr>
			<td>Jumlah Data : $jml</td>
			<td align='right'>Halaman :";
		if (!empty($cari)){
			for ($h = 1; $h <= $max; $h++) {
					$list[$h] = $lim * $h - $lim;
					echo " <a href='javascript:void(0)' ";?> 
                    onClick="$.get('spv/st_group/tampil_data.php?cari=<?php echo $_GET[cari];?>&hal=<?php echo $list[$h]; ?>', 
                    null, function(data) {$('#tampil_data').html(data);})" <?php echo">".$h."</a> ";
				}		
		}
		else{
			for ($h = 1; $h <= $max; $h++) {
					$list[$h] = $lim * $h - $lim;
					echo " <a href='javascript:void(0)' ";?> 
                    onClick="$.get('spv/st_group/tampil_data.php?hal=<?php echo $list[$h]; ?>', 
                    null, function(data) {$('#tampil_data').html(data);})" <?php echo">".$h."</a> ";
				}	
		}

	echo "</td>
		</tr>
		</table>";
?>