HTML does not execute when within a PHP variable

0

Good morning, friends.

I'm returning an html code through DB in php, when I echo the variable instead of executing the html code it displays as if it were a text does anyone know how to help me?

Thanks in advance,

<div class="papel" id="papel" style="margin-top:calc(297mm * <?php echo $i?>)!important;background-color:<?php echo $cor ?>">
<?php   
    $listagem = new Consulta();
    $listagem->Conecta();
    $retorno = $listagem->ConsultaDados('cf_codigo', 'dm_id', 'ASC','dm_id=71');
    if(count($retorno) > 0) {
        foreach ($retorno as $linha) {
        // Ao executar essa linha, ao inves do codigo html na variavel ser executado, é é escrito.
            echo $linha->dm_codhtml;
        }
    }
?>
</div>

Result:

    
asked by anonymous 23.06.2016 / 16:04

1 answer

5

HTML code is coming encoded from the database. You need to unclog it.

Instead of doing so:

echo $linha->dm_codhtml;

... do this:

echo html_entity_decode($linha->dm_codhtml);
    
23.06.2016 / 18:28