   <script type="text/javascript">
        
$(document).ready(function() {
    var total_record = 0;
    var brand=check_box_values('brand');
    var material=check_box_values('material');
    var size=check_box_values('size');
    var total_groups = 6;
    $('#results').load("autoload.php?group_no="+total_record+"&brand="+brand+"&material="+material+"&size="+size,  function() {
        total_record++;
    });
    $(window).scroll(function() {       
        if($(window).scrollTop() + $(window).height() == $(document).height())  
          
        {    
            if(total_record <= total_groups)
            {
                loading = true;
                $('.loader').show();
                $.get("autoload.php?group_no="+total_record+"&brand="+brand+"&material="+material+"&size="+size,
                function(data){ 
                if (data != "") {                               
                    $("#results").append(data);
     //   location.reload();

                    $('.loader').hide();                  
                    total_record++;
                }
                });     
            }
                // total_record ++;
        }
    });
    function check_box_values(check_box_class){
        var values = new Array();
            $("."+check_box_class+":checked").each(function() {
               values.push($(this).val());
            });
        return values;
    }
	$(".sort_rang").change(function(){
   $("#search_form").submit();
        return false;
});
});

</script>
	<?php
 include("config/koneksi2.php");
 $all_brand=mysql_query("SELECT distinct brand FROM bs_stok WHERE tipe = 'BIKE' GROUP BY brand");
$all_material=mysql_query("SELECT distinct kategori FROM bs_stok WHERE tipe = 'BIKE' GROUP BY kategori");
$all_size=mysql_query("SELECT distinct size_ax FROM bs_stok WHERE tipe = 'BIKE' GROUP BY size_ax");

// Filter query
  /* $sql="SELECT * FROM bs_stok WHERE tipe = 'BIKE'";
    if(isset($_GET['brand']) && $_GET['brand']!="") :
        $brand = $_GET['brand'];
        $sql.=" AND brand IN ('".implode("','",$brand)."')";
    endif;

    if(isset($_GET['material']) && $_GET['material']!="") :
        $material = $_GET['material'];
        $sql.=" AND kategori IN ('".implode("','",$material)."')";
    endif;

    if(isset($_GET['size']) && $_GET['size']!="") :
        $size = $_GET['size'];
        $sql.=" AND size_ax IN (".implode(',',$size).")";
    endif;
    $all_product=mysql_query($sql);
    $content_per_page = 3;
    $rowcount=mysql_num_rows($all_product);
    $total_data = ceil($rowcount / $content_per_page);*/
    function data_clean($str)
    {
        return str_replace(' ','_',$str);
    }
 ?>
     <aside class="col-lg-3 col-md-4">
                        <div class="panel list">
                            <div class="panel-heading"><h3 class="panel-title" data-toggle="collapse" data-target="#panelOne" aria-expanded="true">Shop by Brand</h3></div>
                            <div class="panel-body collapse out" id="panelOne">
                                <ul class="list-group">
                                <?php while ($new_brand=mysql_fetch_array($all_brand))
								{
                                    if(isset($_GET['brand'])) :
                                        if(in_array(data_clean($new_brand['brand']),$_GET['brand'])) : 
                                            $check='checked="checked"';
                                        else : $check="";
                                        endif;
                                    endif;
                                ?>
                                    <li class="list-group-item">
                                        <div class="checkbox"><label><input type="checkbox" value="<?=data_clean($new_brand['brand']);?>" <?=@$check?> name="brand[]" class="sort_rang brand"><?=ucfirst($new_brand['brand']); ?></label></div>
                                    </li>
                                <?php } ?>
                                </ul>
                            </div>
                        </div>
                        <div class="panel list">
                            <div class="panel-heading"><h3 class="panel-title" data-toggle="collapse" data-target="#panelTwo" aria-expanded="true">Shop by Kategori</h3></div>
                            <div class="panel-body collapse out" id="panelTwo">
                                <ul class="list-group">
                                <?php while($new_material=mysql_fetch_array($all_material))
								{
                                    if(isset($_GET['material'])) :
                                        if(in_array(data_clean($new_material['kategori']),$_GET['material'])) : 
                                            $material_check='checked="checked"';
                                        else : $material_check="";
                                        endif;
                                    endif;
                                ?>
                                    <li class="list-group-item">
                                        <div ><label><input type="checkbox" value="<?=data_clean($new_material['kategori']); ?>" <?=@$material_check?>  name="material[]" class="sort_rang material"><?=ucfirst($new_material['kategori']); ?></label></div>
                                    </li>
                                <?php } ?>
                                </ul>
                            </div>
                        </div>
                        <div class="panel list">
                            <div class="panel-heading"><h3 class="panel-title" data-toggle="collapse" data-target="#panelThree" aria-expanded="true">Shop by Size</h3></div>
                            <div class="panel-body collapse out" id="panelThree">
                                <ul class="list-group">
                                    <?php while($new_size=mysql_fetch_array($all_size))
									{
                                        if(isset($_GET['size'])) :
                                            if(in_array($new_size['size_ax'],$_GET['size'])) : 
                                                $size_check='checked="checked"';
                                            else : $size_check="";
                                            endif;
                                        endif;
                                    ?>
                                    <li class="list-group-item">
                                        <div><label><input type="checkbox" value="<?=$new_size['size_ax']; ?>" <?=@$size_check?>  name="size[]" class="sort_rang size"><?=$new_size['size_ax']; ?></label></div> 
									   <div>
									   		
									   </div>
                                    </li>
                                <?php } ?>
                                </ul>
                            </div>
                        </div>
                    </aside>

