I'm try to build a online shopping website. In this I add the feature of sorting products by price etc. using select dropdown but not working?

When I select any of the options from the dropdown I get the value in URL but the below products are not sorting. Why is this not working? What am I doing wrong in the code?

HTML Code:

<div class="htc__select__option">
          <select class="ht__select" onchange="sort_product_drop('<?php echo $cat_id?>','<?php echo 'http://localhost/Final%20year%20project/Front-Side/'?>')" id="sort_product_id">
                <option value="">Default softing</option>
                <option value="price_low"  <?php echo $price_low_selected?>>Sort by price low to hight</option>
                <option value="price_high"  <?php echo $price_high_selected?>>Sort by price high to low</option>
                <option value="new"  <?php echo $new_selected?>>Sort by new first</option>
                <option value="old"  <?php echo $old_selected?>>Sort by old first</option>
         </select>
                            
</div> 

PHP Code:

$cat_id=mysqli_real_escape_string($con,$_GET['id']);
$get_product=get_product($con,'',$cat_id,'','','',$sort_order,$sub_categories);
$price_high_selected="";
$price_low_selected="";
$new_selected="";
$old_selected="";
$sort_order='';

if(isset($_GET['sort'])){
$sort=mysqli_real_escape_string($con,$_GET['sort']);


if($sort=="price_high"){
$sort_order=" order by products.price desc ";
$price_high_selected="selected";
}

if($sort=="price_low"){
$sort_order=" order by products.price asc ";
$price_low_selected="selected";
}

if($sort=="new"){
$sort_order=" order by products.p_id desc ";
$new_selected="selected";
}

if($sort=="old"){
$sort_order=" order by products.p_id asc ";
$old_selected="selected";
    }

}

JS Code

function sort_product_drop(cat_id){
        var sort_product_id=jQuery('#sort_product_id').val();
        //alert(cat_id);
       window.location.href="http://localhost/Final%20year%20project/Front-Side/categories.php?id="+cat_id+"&sort="+sort_product_id;
    }

Function file code:

function get_product($con,$limit='',$cat_id='',$product_id='',$search_str='',$sort_order='',$sub_categories='')
{
    
    $query = "SELECT * from products";
    if($cat_id!=''){
        $query=" select * from products where categories_id=$cat_id ";
    }
    if($product_id!=''){
        $query=" select * from products where p_id=$product_id ";
    }
    if($sub_categories!=''){
        $query.=" and products.sub_categories_id=$sub_categories ";
    }
    if($search_str!=''){
        $query=" SELECT * FROM products WHERE products.name like '%$search_str%'";
    }
    if($sort_order!=''){
        $query.=$sort_order;
    }else{
        $query.=" order by products.p_id desc ";
    }
    if($limit!=''){
        $query.=" limit $limit";
    }
    //echo $query;
    $res=mysqli_query($con,$query);
    $data=array();
    while($row=mysqli_fetch_assoc($res)){
        $data[]=$row;
    }
    return $data;
}