HTML tag not shown

Asked

Viewed 112 times

1

I make a query in a given table and the result is as follows:

<p><span style="font-size:14px;"><strong><span style="color: rgb(120, 120, 120); font-family: &quot;Trebuchet MS&quot;, Arial, Helvetica, sans-serif;">texto texto</span></strong></span></p>

So far so good but when I put an echo $dados3['Description'] that has this result above it writes exactly as pasted above, it does not format.

I want you to run the page and use these html tags as saved in the database, but if it is not possible how can I delete everything else and leave only the text pure?

  • Use echo strip_tags($dados3['description']); will print only the text.

  • Yes I had already used but it seems that he ignores this command the output is the same there I described above, very strange.

  • I think you could put more information in the question. Puts a print of how it appears in the database and how it appears in inspecting browser elements, and how it is doing this echo in HTML. This problem can be because of mts things, and only with this information in the question becomes difficult to give any answer.

2 answers

1


Just use the native PHP function html_entity_decode();

$result = '&#60;br&#62;';

echo $result; // <br>

Instead of that, use:

echo html_entity_decode($result) // Então navegador irá interpretar esse código

0

Supplementing the question:

In the database it is recorded this way:

&lt;p style=&quot;margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Produto feito 100% Artesanalmente com todo carinho e dedicação que as artesãs merecem.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Além de um item super útil para seu ateliê, pela sua elegância e sofisticação também é uma peça de decoração para o seu ateliê.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;&quot;&gt;&lt;strong style=&quot;color: rgb(97, 11, 90); font-family: Acme; font-size: 14px; margin: 0px; padding: 0px;&quot;&gt;Produto Exclusivo do Ateliê Cris Ramos.&lt;/strong&gt;&lt;br&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;Obs.: Alfinetes não estão incluídos&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;br&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; margin: 0px; padding: 0px;&quot;&gt;&lt;font color=&quot;#ff0000&quot; face=&quot;Arial Black&quot;&gt;Este produto pode ser trocado por 500 pontos do programa de fidelidade&lt;/font&gt;&lt;/strong&gt;&lt;br&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;

The Field in mysql is:
Name Field Type Glue Description text utf8_general_ci

The php search I do is simple:

$sql3 = "SELECT `description` FROM `oc_product_description` WHERE `product_id` = '5'";
$query3 = mysqli_query($conn, $sql3);
while ($dados3 = mysqli_fetch_array($query3)) {
  $descricao = strip_tags($dados3['description']);
}

In giving echo the result is this:

<p style="margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;"><span style="margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;"><strong style="margin: 0px; padding: 0px;">Produto feito 100% Artesanalmente com todo carinho e dedicação que as artesãs merecem.</strong></span></p><p style="margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;"><span style="margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;"><strong style="margin: 0px; padding: 0px;">Além de um item super útil para seu ateliê, pela sua elegância e sofisticação também é uma peça de decoração para o seu ateliê.</strong></span></p><p style="margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;"><strong style="color: rgb(97, 11, 90); font-family: Acme; font-size: 14px; margin: 0px; padding: 0px;">Produto Exclusivo do Ateliê Cris Ramos.</strong><br></p><p style="margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;"><span style="margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;"><strong style="margin: 0px; padding: 0px;">Obs.: Alfinetes não estão incluídos</strong></span></p><p style="margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;"><span style="margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;"><strong style="margin: 0px; padding: 0px;"><br></strong></span></p><p style="margin-bottom: 10px; padding: 0px; color: rgb(102, 102, 102); font-size: 12px;"><span style="margin: 0px; padding: 0px; line-height: 20px; color: rgb(97, 11, 90); font-family: Acme; font-size: 14px;"><strong style="margin: 0px; padding: 0px;"><strong style="color: rgb(0, 0, 0); font-family: &quot;Open Sans&quot;, sans-serif; margin: 0px; padding: 0px;"><font color="#ff0000" face="Arial Black">Este produto pode ser trocado por 500 pontos do programa de fidelidade</font></strong><br></strong></span></p>
  • I managed to solve the problem with html_entity_decode, instead of using strip_tags I used html_entity_decode and it worked, someone had answered but ended up erasing the answer , I thank this person who ended up not being able to see the name.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.