php - JQuery price selector slider not working properly ()
The following codes are used for a price selector function in my website.
index.php
<input type="hidden" id="hidden_minimum_price" value="1000" />
<input type="hidden" id="hidden_maximum_price" value="95000" />
<p id="price_show">1000 - 95000</p>
<div id="price_range"></div>
...some other codes....
<script>
$(document).ready(function(){
filter_data();
function filter_data()
{
$('.filter_data').html('<div id="loading" style="" ></div>');
var action = 'fetch_data';
var minimum_price = $('#hidden_minimum_price').val();
var maximum_price = $('#hidden_maximum_price').val();
var brand = get_filter('brand');
var ram = get_filter('ram');
var storage = get_filter('storage');
var bcamera = get_filter('bcamera');
var core = get_filter('core');
var battery = get_filter('battery');
var page = get_filter('page');
$.ajax({
url:"fetch_data.php",
method:"POST",
data:{action:action, minimum_price:minimum_price, maximum_price:maximum_price, brand:brand, ram:ram, storage:storage, bcamera:bcamera, core:core, battery:battery, page:page},
success:function(data){
$('.filter_data').html(data);
}
});
}
function get_filter(class_name)
{
var filter = [];
$('.'+class_name+':checked').each(function(){
filter.push($(this).val());
});
return filter;
}
$('.common_selector').click(function(){
filter_data();
});
$('#price_range').slider({
range:true,
min:1000,
max:95000,
values:[1000, 95000],
step:500,
stop:function(event, ui)
{
$('#price_show').html(ui.values[0] + ' - ' + ui.values[1]);
$('#hidden_minimum_price').val(ui.values[0]);
$('#hidden_maximum_price').val(ui.values[1]);
filter_data();
}
});
});
</script>
Every other filter functions are working properly. If I set the price filter from 5000-95000, all products are supposed to show. But the products with price showing above 10000 are not showing in the result. If I move the filter above 10000, it starts to work. What could be wrong?. You can visit the webpage and try the price slier to get an idea.
fetch_data.php
$queryy = "
SELECT * FROM filterr WHERE product_status = '1'
";
if(isset($_POST["minimum_price"], $_POST["maximum_price"]) && !empty($_POST["minimum_price"]) && !empty($_POST["maximum_price"]))
{
$queryy .= "
AND product_price BETWEEN '".$_POST["minimum_price"]."' AND '".$_POST["maximum_price"]."'
";
}
Answer
Solution:
I fixed it by saving the price details in a separate column and changing the code accordingly. Product_price column format was decimal(8,2) and price format was without the ",2".
Source