PHP price Range search using Jquery

jQuery UI slider is used for selecting min-max ranges to perform the range-based operations like search, validation, and more.

The min-max ranges are set by using the two drag handles of the jQuery UI slider. After setting the min and the max ranges the selected area between the two drag handles is highlighted.

set ranges
set ranges

- Advertisement -

I have used this jQuery range slider for selecting product price ranges. Based on the selected price ranges, I filtered the product data from the database. While dragging the min-max handles, the minimum and the maximum range is displayed dynamically by using appropriate edit boxes. The user can also directly enter their range input using these min-max input boxes.

Range Slider Input HTML

This HTML code contains a target container to be replaced as a range slider. With the reference this element, the jQuery UI slider is called to show the range slider with the default min-max ranges. While dragging the range handlers the min-max values are updated dynamically on the input boxes.

<link rel="stylesheet"
    href="" />
<script src=""></script>
<script src=""></script>
<div class="form-price-range-filter">
    <form method="post" action="">
            <input type="" id="min" name="min_price"
                value="<?php echo $min; ?>">
            <div id="slider-range"></div>
            <input type="" id="max" name="max_price"
                value="<?php echo $max; ?>">
            <input type="submit" name="submit_range"
                value="Filter Product" class="btn-submit">

PHP Code for Filtering Product Data Based on Price Range

This PHP code receives the minimum and the maximum price range input data posted via the HTML form. Using these ranges the query is created to filter the product data from the database. The resultant array is iterated and the product data is displayed in a tabular form.

$conn = mysqli_connect("localhost", "root", "test",
$result = mysqli_query($conn, "select *
from tbl_product where price BETWEEN '$min'
AND '$max'");
$count = mysqli_num_rows($result);
if ($count > 0) {
    <div class="container">
        <table class="tutorial-table"
cellspacing="1px" width="100%">
                <th>Product name</th>
                <th class="text-right">Price (in $)
    while ($row = mysqli_fetch_array($result)) {
                <td><img class="product-thumb"
src="<?php echo $row['image']; ?>" />
<?php echo $row['name']; ?></td>
                <td><?php echo $row['code']; ?></td>
                <td class='text-right'>
<?php echo $row['price']; ?></td>
    } // end while
} else {
<div class="no-result">No Results</div>
echo $output;

PHP Price Range Slider Output

PHP Price Range Slider Output
PHP Price Range Slider Output

This screenshot shows the price range slider with the default min-max range. Also, it displays the filtered product data from the database.

Popular Categories

Popular Read

94196eb2zf3ilov?a aid=61645c41311de&a bid=94196eb2
Samuel Jim
Samuel Jim Nnamdi is the CTO of Foxstate, a platform that powers digital infrastructures for Real estate financing globally. He has over 8 years of Software Engineering and CyberSecurity expertise.

Related Articles


Please enter your comment!
Please enter your name here