There are two menus and both were made in order to filter the main content of my website. The Menu one will filter the category and the Menu two will filter the brand.
When clicking in a menu 01 option, it will output: mywebsite.com/?cat=accessories
When clicking in a menu 02 option, it will output: mywebsite.com/?brand=medicate
My main question is how can I get both together when one of them is already set, something like: mywebsite.com/?category=accessories&brand=medicate
Here is my basic code:
<h1>Menu One</h1>
<ul>
<li><a href="?category=accessories">Option 01</a></li>
<li><a href="?category=bolts">Option 01</a></li>
<li><a href="?category=tools">Option 01</a></li>
</ul>
<h1>Menu Two</h1>
<ul>
<li><a href="&brand=medicate">Brand 01</a></li>
<li><a href="&brand=diasyst">Brand 02</a></li>
<li><a href="&brand=clement">Brand 03</a></li>
</ul>
When you're displaying the menus, if one of the other filters is already set, you can add that to the URL in the other menu.
$cat = isset($_GET['category']) ? '&category=' . $_GET['category'] : '';
$brand = isset($_GET['brand']) ? '&brand=' . $_GET['brand'] : '';
?>
<h1>Menu One</h1>
<ul>
<li><a href="?category=accessories<?php echo $brand ?>">Option 01</a></li>
<li><a href="?category=bolts<?php echo $brand ?>">Option 01</a></li>
<li><a href="?category=tools<?php echo $brand ?>">Option 01</a></li>
</ul>
<h1>Menu Two</h1>
<ul>
<li><a href="?brand=medicate<?php echo $cat ?>">Brand 01</a></li>
<li><a href="?brand=diasyst<?php echo $cat ?>">Brand 02</a></li>
<li><a href="?brand=clement<?php echo $cat ?>">Brand 03</a></li>
</ul>
I don't know if I'm understanding right your question but it seems to me you want to do?
<h1>Menu Join</h1>
<ul>
<li><a href="?brand=medicate&category=accessories">Brand 01</a></li>
<li><a href="?brand=diasyst&category=accessories">Brand 02</a></li>
<li><a href="?brand=clement&category=accessories">Brand 03</a></li>
</ul>
i guess that's what you are asking for:
<h1>Menu One</h1>
<ul>
<li><a href="?brand=<?php echo $_GET["brand"]; ?>&category=accessories">Option 01</a></li>
<li><a href="?brand=<?php echo $_GET["brand"]; ?>&category=bolts">Option 01</a></li>
<li><a href="?brand=<?php echo $_GET["brand"]; ?>&category=tools">Option 01</a></li>
</ul>
<h1>Menu Two</h1>
<ul>
<li><a href="?brand=medicate&category=<?php echo $_GET["category"]; ?>">Brand 01</a></li>
<li><a href="?brand=diasyst&category=<?php echo $_GET["category"]; ?>">Brand 02</a></li>
<li><a href="?brand=clement&category=<?php echo $_GET["category"]; ?>">Brand 03</a></li>
</ul>
this will work for your exact case.
You will need to add the known parameter to the links as well.
<?php
$category = isset($_GET['category']) ? '&category='.$_GET['category'] : '');
$brand = isset($_GET['brand']) ? '&brand='.$_GET['brand'] : '');
?>
<h1>Menu One</h1>
<ul>
<li><a href="?category=accessories<?php echo $brand; ?>">Accessories</a></li>
<li><a href="?category=bolts<?php echo $brand; ?>">Bolts</a></li>
<li><a href="?category=tools<?php echo $brand; ?>">Tools</a></li>
</ul>
<h1>Menu Two</h1>
<ul>
<li><a href="?brand=medicate<?php echo $category; ?>">Medicate</a></li>
<li><a href="?brand=diasyst<?php echo $category; ?>">Diasyst</a></li>
<li><a href="?brand=clement<?php echo $category; ?>">Clement</a></li>
</ul>
Considering you are using PHP, you can compile the menu a lot more dynamically than hardcoding all options. But an explanation of that is beyond this question. Consider that just a general tip.