jeudi 29 octobre 2015

How to implement the filter through checkbox's(php, ajax)

How to implement a filter that will show only those blocks that have relevant information, while all others hide? There is a table "Areas", "Street", and the main table "Hotels". In the table "Hotels" has columns "Region", "Street". They record the name of the area or street at, and not give id from the tables. For example, there is an area "Region12"(made in the form of a checkbox), and when we click on this box, find the block with the information in the database the value of the area "Region12" and others will disappear. I note that in the filter you can choose many values: for Example, the area "Region12", you can select a street "Street12", "Street13" and will display hotels in the area. In General, multi-checkboxes. Maybe there is some other option? Please help.

  <form action="index.php" method="post">
    <div id="filter_c">
        <div class="Region">
          <span>Region</span>
              <div class="filter_l"> 
                <?php foreach ($region as $id => $region): ?>
                    <div class="kbox">
                    <input type="checkbox" id="region_<?=$id;?>" value="<?=$id;?>" name="region[]" />
                      <label for="region_<?=$id;?>">
                        <span class="filter_name"><?=$region['region'];?></span>
                      </label>
                    </div>
                <?php endforeach; ?>
              </div>
        </div>
        <div class="street">
          <span>Street</span>
              <div class="filter_l"> 
                <?php foreach ($street as $id => $street): ?>
                    <div class="kbox">
                    <input type="checkbox" id="street_<?=$id;?>" value="<?=$id;?>" name="street[]" />
                      <label for="street_<?=$id;?>">
                        <span class="filter_name"><?=$street['street'];?></span>
                      </label>
                    </div>
                <?php endforeach; ?>
              </div>            
        </div>             
      </div>
  </form> 

Block with information about Hotels

<div class="desc">
  <h2><?=$hotel['name']?></h2>
   <p>Region: <?=$hotel['region']?></p>
   <p>Street: <span><?=$hotel['street']?></span></p>
</div>



Aucun commentaire:

Enregistrer un commentaire