Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8052607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:35:10+00:00 2026-06-05T07:35:10+00:00

I want to filter my search results based on some parameters using checkboxes .I

  • 0

I want to filter my search results based on some parameters using checkboxes.I have a search function alongwith pagination working,but all written in PHP.Now I want to filter the records,but this will need ajax requests and jquery probably and I am not good at it.Something similar done here http://www.proptiger.com/property-in-pune-real-estate.php The left panel has checkboxes to filter data.
This is the div which holds the search query and displays results.

           <div class="flt width710" id="displayProp">
            <div style="margin-top:10px;" class="flt mapnewalert"> <?php //echo ucfirst($_SESSION['$cityName']) ?></div>
            <div style="float:right" id="toppagesel">
            <?php   

    /*****************Query for taking the count of the values of search criteria *********************** */
                        $countQuery = "Select count(*) as total from properties inner join cities on properties.city_id=cities.city_id inner join locality on properties.locality_id=locality.locality_id inner join properties_type on properties.property_id=properties_type.property_id where (cities.city_name like '%".$_SESSION['$cityName']."%' and locality.locality_name like '%".$_SESSION['$localityName']."%') or (property_price_min between '".$_SESSION['$minPrice']."' and '".$_SESSION['$maxPrice']."') or (property_price_max between '".$_SESSION['$minPrice']."' and '".$_SESSION['$maxPrice']."') or properties_type.bed_type='".$_SESSION['$bedType']."' ";
                        //print_r($countQuery);
                        $result1 = mysql_query($countQuery);
                        //echo($result1[0]);
                        $queryCount = mysql_fetch_row($result1);
                        //print_r($queryCount);
                        //echo($result1[total]);
                        //exit;
                        $pages->items_total = $queryCount[0];
                        //echo ($pages->items_total);
                        $pages->mid_range = 2;

                        $pages->paginate();
                        echo $pages->display_pages();       
                        echo $pages->display_items_per_page();

                        $query = "SELECT * from properties inner join cities on properties.city_id=cities.city_id inner join locality on properties.locality_id=locality.locality_id inner join properties_type on properties.property_id=properties_type.property_id where (cities.city_name like '%".$_SESSION['$cityName']."%' and locality.locality_name like '%".$_SESSION['$localityName']."%') or (property_price_min between '".$_SESSION['$minPrice']."' and '".$_SESSION['$maxPrice']."') or (property_price_max between '".$_SESSION['$minPrice']."' and '".$_SESSION['$maxPrice']."') or (properties_type.bed_type='".$_SESSION['$bedType']."') $pages->limit";

            $result = mysql_query($query) or die(mysql_error());

            //}
            //echo $query;  
            //$getProperty =    $propertyDetails->getPropertyDetailsByCityIdPaginate($_SESSION['$cityId'],$limit);
            ?>
            </div>
        </div>

I understand I would have to write a js function on check of the checkbox,and pass the parameter to a .php page and process a query to return result,but not sure how to do it and replace the current records in the above with the filtered records along with pagination.
This is my pagination class for reference

class Paginator{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $limit;
var $return;
var $default_ipp;
//var $querystring;
var $ipp_array;

function Paginator()
{
    $this->current_page = 1;
    $this->mid_range = 2;
    $this->ipp_array = array(2,4,6,8,10,'All');
    $this->items_per_page = (!empty($_GET['ipp'])) ? $_GET['ipp']:$this->default_ipp;
}

function paginate()
{
    if(!isset($this->default_ipp)) $this->default_ipp='8';
    if($_GET['ipp'] == 'All')
    {
        $this->num_pages = 1;
       //$this->items_per_page = $this->default_ipp;
    }
    else
    {
        if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
        $this->num_pages = ceil($this->items_total/$this->items_per_page);
    }
    $this->current_page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1 ; // must be numeric > 0
    $prev_page = $this->current_page-1;
    $next_page = $this->current_page+1;
    if($_GET)
    {
        $args = explode("&",$_SERVER['QUERY_STRING']);
        foreach($args as $arg)
        {
            $keyval = explode("=",$arg);
            if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;
        }
    }

    if($_POST)
    {
        foreach($_POST as $key=>$val)
        {
            if($key != "page" And $key != "ipp") $this->querystring .= "&$key=$val";
        }
    }
    if($this->num_pages > 4)
    {
        $this->return = ($this->current_page > 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$prev_page&ipp=$this->items_per_page$this->querystring\">&laquo; Previous</a> ":"<span class=\"inactive\" href=\"#\">&laquo; Previous</span> ";

        $this->start_range = $this->current_page - floor($this->mid_range/2);
        $this->end_range = $this->current_page + floor($this->mid_range/2);

        if($this->start_range <= 0)
        {
            $this->end_range += abs($this->start_range)+1;
            $this->start_range = 1;
        }
        if($this->end_range > $this->num_pages)
        {
            $this->start_range -= $this->end_range-$this->num_pages;
            $this->end_range = $this->num_pages;
        }
        $this->range = range($this->start_range,$this->end_range);

        for($i=1;$i<=$this->num_pages;$i++)
        {
            if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
            // loop through all pages. if first, last, or in range, display
            if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
            {
                $this->return .= ($i == $this->current_page And $_GET['page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
            }
            if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
        }
        $this->return .= (($this->current_page < $this->num_pages And $this->items_total >= 10) And ($_GET['page'] != 'All') And $this->current_page > 0) ? "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$next_page&ipp=$this->items_per_page$this->querystring\">Next &raquo;</a>\n":"<span class=\"inactive\" href=\"#\">&raquo; Next</span>\n";
        $this->return .= ($_GET['page'] == 'All') ? "<a class=\"current\" style=\"margin-left:10px\" href=\"#\">All</a> \n":"<a class=\"paginate\" style=\"margin-left:10px\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
    }
    else
    {
        for($i=1;$i<=$this->num_pages;$i++)
        {
            $this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
        }
        $this->return .= "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
    }
    $this->low = ($this->current_page <= 0) ? 0:($this->current_page-1) * $this->items_per_page;
    if($this->current_page <= 0) $this->items_per_page = 0;
    $this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_items_per_page()
{
    $items = '';
    if(!isset($_GET[ipp])) $this->items_per_page = $this->default_ipp;
    foreach($this->ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n";
    return "<span class=\"paginate\">Items per page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n";
}
function display_jump_menu()
{
    for($i=1;$i<=$this->num_pages;$i++)
    {
        $option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n";
    }
    return "<span class=\"paginate\">Page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n";
}
function display_pages()
{
    return $this->return;
}

}

How can achieve the filter part in my scenario??Any help would be appreciated.

EDIT:
process.php

    <?php session_start();

    include_once("includes/classes/db_connect.php");
    include_once("pagination/paginator.class.php");

    $value = $_POST['check']; 
    echo $value;

    $sql="SELECT * from properties inner join cities on properties.city_id=cities.city_id inner join suburbs on properties.suburb_id=suburbs.suburb_id where (cities.city_name like '%".$_SESSION['$cityName']."%' and suburbs.suburb_name like '%".$value."%')  $pages->limit";

    echo $sql;
    $result = mysql_query($sql);
    //$data = mysql_fetch_assoc($result);
    /*echo "<pre>" ;
    print_r($data);
    echo "</pre>" ; */
    while($row=mysql_fetch_assoc($result))
    {
            ?>
          <div class="projectlisttiger">        

        <div class="spacer5">&nbsp;</div>
                    <div class="listnewimg flt">
                        <a href="p-kolte-patil-cilantro-wagholi-pune.php">
                            <!--<img src="admin/uploads/<?php echo ($row['property_cover_image']) ?>" width="186" height="125" border="0">
                            <img src="admin/uploads/Cilantra1/1cilantra-large.jpg" width="186" height="125" border="0">-->
                        </a>
                         <div class="newlistlaunch"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><img width="65" height="65" border="0" src="images/projects/kolte-patil/cilantra/new_launch_blue.png"></a>
                         </div>                             
                    </div>

                    <div class="listright">
                        <div style="width:498px; height:42px;" class="flt">
                            <div class="list-logo flt">
                                <div class="buildborder"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><img width="80" height="36" border="0" align="absmiddle" alt="Kolte Patil" src="admin/uploads/<?php echo $row['builder_logo']?>"></a>
                                </div>
                                   <div class="tablistname"><a href="p-kolte-patil-cilantro-wagholi-pune.php"><?php echo $row['property_name'] ?></a></div>
                            </div>   
                            <?php if ($row['property_price_min']!=0) { ?>      
                            <div class="listprice">
                                <img width="18" height="18" align="absmiddle" src="images/city/rupee_icon.gif"> <?php echo $row['property_price_min'] ?> Lacs - <?php echo $row['property_price_max'] ?> Lacs       
                            </div>
                            <?php } else { ?>
                            <div class="listprice">
                                 <img width="18" height="18" align="absmiddle" src="images/city/rupee_icon.gif">Price on Request
                            </div>
                            <?php } ?>

                        </div>

                            <div class="spacer3">&nbsp;</div>        

                        <div class="listbox">
                            <a href="p-kolte-patil-cilantro-wagholi-pune.php"><strong>Address</strong>:<?php echo $row['locality_name'] ?>, <?php echo $row['city_name'] ?><br> <strong>Types</strong>: 2BHK &amp; 3BHK
                            <br><strong>Sizes:</strong> <?php echo $row['property_size_min'] ?> sqft - <?php echo $row['property_size_max'] ?> sqft </a>
                        </div>

                        <div style="margin-left:-3px;" class="flt">
                            <div style="width:110px;" class="flt"><a style="text-decoration:none;" href="p-kolte-patil-cilantro-wagholi-pune.php"><input type="button" value="View Details" class="detail_project"></a>
                            </div>     
                          <div style="width:110px;" class="flt"><input type="button" onClick="showEnqForm('2659','Cilantro'); return false;" value="Enquire Now" class="enquire_project"></div>
                        </div>
                               <div class="spacer">&nbsp;</div>                                 
                    </div>
                    <div class="spacer15">&nbsp;</div>              
           </div>
<?php
    }
?>

EDIT::Resolved the display part by using this in the js file

       function changeResults(){
        var data = { 'venue[]' : []};
    $("input:checked").each(function() {
            var chck1 = $(this).val();
        //alert(chck1);
        data['venue[]'].push($(this).val());        
    });

 $.ajax({
  type : 'POST',
  url : 'process.php',
  data : data,
  success : function(data){
      $('#project_section').html(data); // replace the contents coming from php file
        }  
    });
}

But my pagination just doesn’t work as it is in php.I have added paginator class.How can i fix this for the pagination to work with the response also.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:35:12+00:00Added an answer on June 5, 2026 at 7:35 am

    Use onchange event of javascript on checkbox and call function here is the function

    function changeResults(){
        // Now get the values of checkbox
        var chk1 = $('#checkbox1').val(); // checkbox1 is id of checkbox
        $.ajax({
         type : 'POST',
         url : 'process.php';
         data : 'check='+chk1,
         success : function(data){
              $('#data-div').html(data); // replace the contents coming from php file
         }  
        });
    }
    

    seperate your php file

    $value = $_POST['check']; 
    

    And now put this $value in your query in condition

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a search page which allows users to further filter thier results based
I have a form with a checkbox that's used to filter some search results.
I'm using django and have a page of search results that I want to
I am using the filter icontains to search for words but I only want
I have a search page and want to add some filters to it, my
I want to filter based on an attribute called level. Where I have written
We have some search functionality that can return tens of thousands of results from
I'm creating a stored procedure to return search results where some of the parameters
I want to filter my model object using two filters. So, it can be
I want to filter a java.util.Collection based on a predicate.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.