Menu with class active in php?

0

I have a menu in html:

        <ul>
        <li><a href="#" class="ativa">Página Inicial</a></li>
            <li><a href="servicos">Serviços</a></li>                  
            <li><a href="entretenimento">Entretenimento</a></li>
            <li><a href="festas-e-decoracoes">Festas e Decorações</a></li>
            <li><a href="bares-e-restaurantes">Bares e Restaurantes</a></li>    
            <li><a href="beleza-e-estetica">Beleza e Estética</a></li>
            <li><a href="hoteis-e-pousadas">Hotéis e Pousadas</a></li>
            <li><a href="esportes-e-suplementos">Esportes e Suplementos</a></li>
            </ul>   

But I want it to be in php because of the database I created for a friendly url, for example: / categories / services

How do I make my menu continue with class active, but being done in php?

The code is for a getMenu but I do not know if it is correct.

public function getMenu(){
        $pegar_categorias = "SELECT * FROM 'categorias' ORDER BY id DESC";
        $executar = self::conn()->prepare($pegar_categorias);
        $executar->execute();
        if($executar->rowCount()==0){}else{
            while($categoria = $executar->fetchObject()){
                echo '<li><a href="'.Path.'/categoria/'.$categoria->slug.'">'.$categoria->titulo.'';
                echo '</li>';
            }
        }

    }

Thank you!

    
asked by anonymous 19.09.2016 / 03:11

0 answers