Questa è la pagina di visualizzazione dei giochi da tavolo e riporto la parte relativa alle checkbox sotto esame:
Codice PHP:
...
 <nav id="filtri">        <label for="touch"><span>Filtri</span></label>
...
 <label for="touch4"><span>Categorie</span></label><input type="checkbox" id="touch4" onclick="uncheck3()">                                      <ul class="slide4">                      <form method="POST" name="cat" action="#">                        <li>                          <label>Avventura / Esplorazione</label><input type="checkbox" id="cat1" name="cat[]" onclick="cerca6()" value="Avventura/Esplorazione" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Avventura/Esplorazione") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Animali / Natura</label><input type="checkbox" id="cat2" name="cat[]" onclick="cerca6()" value="Animali/Natura/Ambiente" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Animali/Natura/Ambiente") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Bluffing</label><input type="checkbox" id="cat3" name="cat[]" onclick="cerca6()" value="Bluffing" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Bluffing") !== false)){ echo "checked";}?>>                        </li>                         <li>                          <label>Costruzione</label><input type="checkbox" id="cat4" name="cat[]" onclick="cerca6()" value="Costruzione" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Costruzione") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Carte</label><input type="checkbox" id="cat5" name="cat[]" onclick="cerca6()" value="Carte"<?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Carte") !== false)){ echo "checked";}?>>                        </li>                          <li>                          <label>Dadi</label><input type="checkbox" id="cat6" name="cat[]" onclick="cerca6()" value="Dadi" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Dadi") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Destrezza / Abilità</label><input type="checkbox" id="cat7" name="cat[]" onclick="cerca6()" value="Destrezza/Abilità" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Destrezza/Abilità")) !== false){ echo "checked";}?>>                        </li>                          <li>                          <label>Fantasy / Medievale</label><input type="checkbox" id="cat8" name="cat[]" onclick="cerca6()"value="Fantasy/Medievale" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Fantasy/Medievale") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Logica / Astratti</label><input type="checkbox" id="cat9" name="cat[]" onclick="cerca6()" value="Logica/Astratti" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Logica/Astratti") !== false)){ echo "checked";}?>>                        </li>                           <li>                          <label>Storici</label><input type="checkbox" id="cat10" name="cat[]" onclick="cerca6()" value="Storici" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Storici") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Gestionali / German</label><input type="checkbox" id="cat11" name="cat[]" onclick="cerca6()" value="Gestionali/German" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Gestionali/German") !== false)){ echo "checked";}?>>                        </li>                           <li>                          <label>Strategici</label><input type="checkbox" id="cat12" name="cat[]" onclick="cerca6()" value="Strategici" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Strategici") !== false)){ echo "checked";}?>>                        </li>                           <li>                          <label>Escape Room/Enigmi</label><input type="checkbox" id="cat13" name="cat[]" onclick="cerca6()" value="Escape Room/Enigmi" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Escape Room/Enigmi") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Sport / Corse</label><input type="checkbox" id="cat14" name="cat[]" onclick="cerca6()" value="Sport/Corse" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Sport/Corse") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Quiz / Trivia</label><input type="checkbox" id="cat15" name="cat[]"  onclick="cerca6()" value="Quiz/Trivia" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Quiz/Trivia") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Pirati</label><input type="checkbox" id="cat16" name="cat[]" onclick="cerca6()" value="Pirati" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Pirati") !== false)){ echo "checked";}?>>                        </li>                         <li>                          <label>Guerra / Tattica</label><input type="checkbox" id="cat17" name="cat[]" onclick="cerca6()" value="Guerra/Tattica" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Guerra/Tattica") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Investigazione / Mistero / Deduzione</label><input type="checkbox" id="cat18" name="cat[]" onclick="cerca6()" value="Investigazione/Mistero/Deduzione" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Investigazione/Mistero/Deduzione") !== false)){ echo "checked";}?>>                        </li>                         <li>                          <label>Horror / Zombie</label><input type="checkbox" id="cat19" name="cat[]" onclick="cerca6()" value="Horror/Zombie" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Horror/Zombie") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>TV / Film /Libri / Musica / Videogiochi</label><input type="checkbox" id="cat20" name="cat[]" onclick="cerca6()" value="Tv/Film/Libri/Musica/Videogiochi" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "TV/Film/Libri/Musica/Videogiochi") !== false)){ echo "checked";}?>>                        </li>                         <li>                          <label>Miniature / American</label><input type="checkbox" id="cat21" name="cat[]" onclick="cerca6()" value="Miniature/American" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Miniature/American") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Party Game</label><input type="checkbox" id="cat22" name="cat[]" onclick="cerca6()"value="Party Game" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Party Game") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Giochi di Parole</label><input type="checkbox" id="cat23" name="cat[]" onclick="cerca6()" value="Giochi di Parole" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Giochi di Parole") !== false)){ echo "checked";}?>>                        </li>                        <li>                          <label>Puzzle</label><input type="checkbox" id="cat24" name="cat[]" onclick="cerca6()" value="Puzzle" <?php if ((ISSET($_SESSION['cat'])) AND (strpos($_SESSION['cat'], "Puzzle") !== false)){ echo "checked";}?>>                        </li>                      </form>

...
if (ISSET($_GET['cat'])){    $cat = htmlspecialchars(strip_tags($_GET['cat']));    $_SESSION['search'] = " && categoria LIKE '%$cat%' ";  }
...
<script type="text/javascript">
function cerca6() {  var cat1 = document.getElementById ( "cat1" ) ;  var cat2 = document.getElementById ( "cat2");  var cat3= document.getElementById("cat3");  var cat4= document.getElementById("cat4");  var cat5= document.getElementById("cat5");  var cat6= document.getElementById("cat6");  var cat7= document.getElementById("cat7");  var cat8= document.getElementById("cat8");  var cat9= document.getElementById("cat9");  var cat10= document.getElementById("cat10");  var cat11= document.getElementById("cat11");  var cat12= document.getElementById("cat12");  var cat13= document.getElementById("cat13");  var cat14= document.getElementById("cat14");  var cat15= document.getElementById("cat15");  var cat16= document.getElementById("cat16");  var cat17= document.getElementById("cat17");  var cat18= document.getElementById("cat18");  var cat19= document.getElementById("cat19");  var cat20= document.getElementById("cat20");  var cat21= document.getElementById("cat21");  var cat22= document.getElementById("cat22");  var cat23= document.getElementById("cat23");  var cat24= document.getElementById("cat24");  var result= " ";  if (cat1.checked == true){    var lg1= document.getElementById("cat1").value;    result= lg1 + "%";  }  if (cat2.checked == true){    var lg2= document.getElementById("cat2").value;    result= result + lg2 + "%";  }  if (cat3.checked == true){    var lg3= document.getElementById("cat3").value;    result= result + lg3 + "%";  }  if (cat4.checked == true){    var lg4= document.getElementById("cat4").value;    result= result + lg4 + "%";  }  if (cat5.checked == true){    var lg5= document.getElementById("cat5").value;    result= result + lg5 + "%";  }  if (cat6.checked == true){    var lg6= document.getElementById("cat6").value;    result= result + lg6 + "%";  }  if (cat7.checked == true){    var lg7= document.getElementById("cat7").value;    result= result + lg7 + "%";  }  if (cat8.checked == true){    var lg8= document.getElementById("cat8").value;    result= result + lg8 + "%";  }  if (cat9.checked == true){    var lg9= document.getElementById("cat9").value;    result= result + lg9 + "%";  }  if (cat10.checked == true){    var lg10= document.getElementById("cat10").value;    result= result + lg10 + "%";  }  if (cat11.checked == true){    var lg11= document.getElementById("cat11").value;    result= result + lg11+ "%";  }  if (cat12.checked == true){    var lg12= document.getElementById("cat12").value;    result= result + lg12 + "%";  }  if (cat13.checked == true){    var lg13= document.getElementById("cat13").value;    result= result + lg13 + "%";  }  if (cat14.checked == true){    var lg14= document.getElementById("cat14").value;    result= result + lg14 + "%";  }  if (cat15.checked == true){    var lg15= document.getElementById("cat15").value;    result= result + lg15 + "%";  }  if (cat16.checked == true){    var lg16= document.getElementById("cat16").value;    result= result + lg16 + "%";  }  if (cat17.checked == true){    var lg17= document.getElementById("cat17").value;    result= result + lg17 + "%";  }  if (cat18.checked == true){    var lg18= document.getElementById("cat18").value;    result= result + lg18 + "%";  }  if (cat19.checked == true){    var lg19= document.getElementById("cat19").value;    result= result + lg19 + "%";  }  if (cat20.checked == true){    var lg20= document.getElementById("cat20").value;    result= result + lg20 + "%";  }  if (cat21.checked == true){    var lg21= document.getElementById("cat21").value;    result= result + lg21 + "%";  }  if (cat22.checked == true){    var lg22= document.getElementById("cat22").value;    result= result + lg22 + "%";  }    if (cat23.checked == true){    var lg23= document.getElementById("cat23").value;    result= result + lg23 + "%";  }    if (cat24.checked == true){    var lg24= document.getElementById("cat24").value;    result= result + lg24 + "%";  }</script>
Questa invece è la pagina "ricerca_chiavi.php", che lavora in background per mostrare i risultati dati dall'aggiunta dei filtri in tempo reale. Ovviamente la pagina è molto più lunga, ma incollo solo la parte di codice incriminata:
Codice PHP:
if (isset($_GET['cat'])){  $_SESSION['cat'] = trim(htmlentities($_GET['cat']));    $_SESSION['pt5'] = " && categoria LIKE '%".$_SESSION['cat']."'";  $_SESSION['msgcat'] = " - Categorie: ".$_SESSION['pt5']; if ($_SESSION['cat']==""){    $_SESSION['msgcat'] ="";  }
if (!ISSET(
$_SESSION['pt5'])) {  $_SESSION['pt5']="";} 
Se può essere utile posso dirvi anche l'url del sito per vederlo in azione, non lo dico subito per non infrangere qualche tipo di regola.

Grazie mille.