S
S
svilkov872015-11-16 16:26:09
PHP
svilkov87, 2015-11-16 16:26:09

Is class active not being set for a button on a page?

Good afternoon!
In the list, the button should be active when the user is on the current page.
Why isn't this happening? where is the mistake?

<div class="header">
        <ul class="nav_menu">
        <?php
        $url = $_SERVER['REQUEST_URI'];
        if($url == "/multipulty.ru/multipulty.ru/o_nas.php")
        {
            $url1 = "active";
        }
        elseif($url == "/multipulty.ru/multipulty.ru/forum.php")
        {
            $url2 = "active";
        }
        else
        {  
          $index = "active";
        }
        
        ?>
            <li class="<?php $index?>"><a href="index.php">Главная</a></li>
            <li class="<?php $url1?>"><a href="o_nas.php">О нас</a></li>
            <li class="<?php $url2?>"><a href="forum.php">Форум</a></li>
        </ul>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2015-11-16
@27cm

echo forgot

<li class="<?php echo $index ?>"><a href="index.php">Главная</a></li>
<li class="<?php echo $url1 ?>"><a href="o_nas.php">О нас</a></li>
<li class="<?php echo $url2 ?>"><a href="forum.php">Форум</a></li>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question