I have a website which is showing products online. In it, I have categories and subcategories listed. When I'm clicking on a category, it doesn't remain active/selected. I have a class="active"
which is added to the selected category when clicked but it doesn't expand on selection.
This is my website www.sitimobil.mk. The example site is www.fixit.mk
On the left side you have the categories and subcategories.
<?php
$qKategori = ("SELECT * FROM kategori WHERE kprind = 0");
$rKategori = mysqli_query($dbc, $qKategori);
if ($rKategori) {
while ($exKat = mysqli_fetch_array($rKategori, MYSQLI_ASSOC)) {
$emrikategorise = $exKat['kemri'];
$idkategori = $exKat['kid'];
$idprind = $exKat['kprind'];
?>
<li><a href="#"><?= $emrikategorise; ?></a>
<ul <?php
if ($_GET['kid'] == $idkategori) {
echo 'class="active"';
}
?>>
<?php
$qPrind = ("SELECT * FROM kategori WHERE kprind = '" . $idkategori . "'");
$rPrind = mysqli_query($dbc, $qPrind);
while ($prind = mysqli_fetch_array($rPrind)) {
?>
<li><a href="kategori.php?kid=<?= $prind['kid'] ?>&kprind=<?= $prind['kprind'] ?>" <?php
if ($_GET['kid'] == 48) {
echo 'class="active"';
}
?>><?= $prind['kemri'] ?></a></li>
<?php
}
mysqli_free_result($rPrind);
?>
</ul>
</li>
<?php
}
mysqli_free_result($rKategori);
}
?>