I know there are better ways to do it, but I really need to create a multiple parameter filter with PHP only in order to filter items by from a json.
The categories are separated by Gender, type of Item, colors etc... I want to be able to select multiple categories, and if only gender is set to show all products, call them using the $_GET method and be able to filter using IFs.
The problem is that my amateur coding skills are not helping much, and I am also not sure if without AJAX there is a better way to do this.
This is what part of my filter looks like:
<ul class="category-menu" name="categoria">
<li><a href="page.php?genid=<?php echo $genid;?>&cat=remeras&col=<?php echo ($_GET["col"]);?>&mar=<?php echo ($_GET["mar"]);?>" name="campera" >Remeras</a></li>
<li><a href="page.php?genid=<?php echo $genid;?>&cat=camperas&col=<?php echo $col;?>&mar=<?php echo $mar;?>" name="campera">Camperas</a></li>
<li><a href="page.php?genid=<?php echo $genid;?>&cat=pantalones&col=<?php echo $col;?>&mar=<?php echo $mar;?>" name="pantalones">Pantalones</a></li>
<li><a href="page.php?genid=<?php echo $genid;?>&cat=shorts&col=<?php echo $col;?>&mar=<?php echo $mar;?>" name="short">Shorts</a></li>
<li><a href="page.php?genid=<?php echo $genid;?>&cat=vestidos&col=<?php echo $col;?>&mar=<?php echo $mar;?>" name="vestido">Vestidos</a></li>
</ul>
And I have my ifs looking like this:
<?php
}elseif ( !empty($_GET["genid"]) && !empty($_GET["cat"]) && $datosArray[$i]["sex_id"] == $_GET["genid"] && $datosArray[$i]["categoria"] == $_GET["cat"]){
?>
<!-- Individual Product full Code -->
...
<!-- /Individual Product full Code -->
<?php
}elseif (!empty($_GET["genid"]) && $datosArray[$i]["sex_id"] == $_GET["genid"]){
?>
<!-- Individual Product full Code -->
...
<!-- /Individual Product full Code -->
<?php
}} ?>
Right now the only "filter" it recognizes is the Gender one and its displaying all products even if the $_GET is set and displayed properly.
Thank you all in advance.