结果过滤器不起作用

I have created a filter result using php but it is not properly working for me when i filter result it is not showing me up with any products. The product size and product color is listed in a different table. When I filter and click on submit it does not show me any products no products are coming up for me though can anyone help me out please below are my code which i have used please let me know.

<form method="POST" action="product.php?cat=<?php echo $cat; ?>">
    <div class="price-box">
        <h5>Price</h5>
        <input type="hidden" name='price_range' class="range-slider" min="0" max="600" value="23" />
    </div>
    <div id="filters">
    <div class="size-box">
    <h5>size</h5>
    <ul>
        <li> <input type="checkbox" id="active" name="size[]" value="S"> <span class="check-txt">S (10)</span></li>
        <li> <input type="checkbox" id="In Stock" name="size[]" value="XL"> <span class="check-txt">XL (10)</span></li>
        <li> <input type="checkbox" id="large" name="size[]" value="L"> <span class="check-txt">L (10)</span></li>
    </ul>
    </div>
    </div>

    <div class="color-box">
        <h5>color</h5>
        <ul>
            <li> <input type="checkbox" name="color[]" value="White"> <span class="check-txt">White (2)</span></li>
            <li> <input type="checkbox" name="color[]" value="Black"> <span class="check-txt">Black (3)</span></li>
            <li> <input type="checkbox" name="color[]" value="Orange"> <span class="check-txt">Orange (3)</span></li>
            <li> <input type="checkbox" name="color[]" value="Blue"> <span class="check-txt">Blue (4)</span></li>
            <li> <input type="checkbox" name="color[]" value="Green"> <span class="check-txt">Green (2)</span></li>
            <li> <input type="checkbox" name="color[]" value="Yellow"> <span class="check-txt">Yellow (1)</span></li>
        </ul>
        </div>
        <input type="submit" name="filter" value="Filter Results" />
    </form>

And here is my php code

    <?php
    $num_rec_per_page=9;
    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
        $start_from = ($page-1) * $num_rec_per_page;                    
        $query = "SELECT * FROM products WHERE product_category = '$cat'";
            if(isset($_POST['filter'])) {
                $query = "SELECT p.* FROM products as p
                JOIN prod_size as ps ON (p.prod_id=ps.prod_id)
                JOIN prod_color as pc ON (p.prod_id=pc.prod_id)
                WHERE ";
                $range = $_POST['price_range'];
                $rg = explode(',', $range);
                $range1 = $rg[0];
                $range2 = $rg[1];
                if($range1!='' && $range2!='') {    
                     $query .= " p.product_price BETWEEN (".$range1." AND ".$range2.") AND ";   
                }

                if(isset($_POST['size']) && is_array($_POST['size'])) {
                     $size = implode(',',$_POST['size']);
                     $query .= " ps.size IN ('".$size."') AND ";        
                }

                if(isset($_POST['color']) && is_array($_POST['color'])) {
                     $color = implode(',',$_POST['color']);
                     $query .= " pc.color  IN ('".$color."') AND ";     
                }
                     $query .= " p.prod_id > 0 ";
            }   

            $query .= " LIMIT ".$start_from.",".$num_rec_per_page;
            $get_prod = mysqli_query($connection, $query);

            $total = mysqli_num_rows($get_prod);
            while($prod = mysqli_fetch_assoc($get_prod)) {
       ?>
        <li class='resultblock' data-tag='<?php echo $prod['status']; ?>'>
            <span class="cbp-vm-image">
            <img src="admin/uplaods/<?php echo $prod['product_image']; ?>" alt="">
                 <ul>
                    <li><a href=""><i class="fa fa-heart"></i></a></li>
                    <li><a href=""><i class="fa fa-refresh"></i></a></li>
                    <li><a href=""><i class="fa fa-search"></i></a></li>
                 </ul>
            </span>

            <p class="cbp-vm-title"><?php echo $prod['product_name']; ?></p>
                 <ul class="cbp-vm-price">
                    <li>$<?php echo $prod['product_price']; ?></li>
                    <li class="pro-rating"><span><i class="fa fa-star"></i></span> <span><i class="fa fa-star"></i></span> <span><i class="fa fa-star"></i></span> <span><i class="fa fa-star"></i></span> <span><i class="fa fa-star"></i></span></li>
                 </ul>
            <a class="cbp-vm-icon cbp-vm-add" href="details.php?pid=<?php echo $prod['prod_id'];?>">View Details</a>
            </li>
            <?php } ?>
        </ul>

Thank You

i think your problem here:

you have to have $cat = $_GET['cat'] before use below code:

 $cat = $_GET['cat']; //add this before
 $query = "SELECT * FROM products WHERE product_category = '$cat'";