0
Good morning friends.
I’m returning an html code through the BD in php, when I echo the variable instead of running the html code it displays as if it were a text someone knows how to help me?
From now on, thank you
<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>
Upshot:
Put in the code you already have
– rray
Hi Anderson! Can you [Edit] the question and join the code you refer to?
– Sergio
@Sergio added the code and an image, I believe that facilitate understanding.
– Anderson
@Anderson, what’s wrong with putting the code in text? So we can use the code in the answer, without it (or as an image) is much more difficult and makes us waste more time to help you...
– Sergio
A similar problem happened to me, so I solved it.(Adapting to your example) echo "{$line->dm_codhtml}";
– Pedro Franco
You could try that code?
echo addslashes($linha->dm_codhtml);
or<<<HTML echo $linha->dm_codhtml HTML;
?– Rafael Withoeft
Pedrofranco and Rafaelwithoeft thank you, I tried both but without success. Both appear the same code identical to figure.
– Anderson
The html presentation by php, not provided by the database
<?php echo <span>teste</span>; ?>
works normally? Or both are displaying the html code on the screen as a text?– Rafael Withoeft
@Rafaelwithoeft performed the test and apparently the problem is when the variable is displayed with database data...
<?php echo "<span>teste</span>"; ?>
This way is executed correctly,– Anderson
@Did Anderson solve it? Would you like to take a closer look at your code, is there another way to contact so I can help you? Email?
– Rafael Withoeft
Hello, thank you very much. I haven’t got it yet, I’m trying, my email is [email protected]
– Anderson