Displaying Html Code within a PHP statement
Moderator: General Moderators
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Displaying Html Code within a PHP statement
Hi all. I'm not sure if I am doing this right, but I some html code that I am pulling from a database via php statement.
<td class="data"><?php echo (nl2br($_data['value'])) ?></td>
The problem is it is displaying the html code not the execution of the html code, ie links, etc.
Is the the proper way to do this?
Thanks
Daniel
<td class="data"><?php echo (nl2br($_data['value'])) ?></td>
The problem is it is displaying the html code not the execution of the html code, ie links, etc.
Is the the proper way to do this?
Thanks
Daniel
Re: Displaying Html Code within a PHP statement
I don't quite understand what you're doing but if you echo html, it will get read as html.
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: Displaying Html Code within a PHP statement
Thats what I thought but for some reason it is not. Take a look on this page at the assembly instructions. It is displaying the html code.
http://www.poly- wood -furniture . (take out spaces) com/polywood-chairs/polywood-adirondack-chairs/polywood-adirondack-chair.html
And I am using the echo command I posted first.
http://www.poly- wood -furniture . (take out spaces) com/polywood-chairs/polywood-adirondack-chairs/polywood-adirondack-chair.html
And I am using the echo command I posted first.
Re: Displaying Html Code within a PHP statement
Is that information stored in a database? Does the entry go through a function that prevents html from being displayed as html?
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: Displaying Html Code within a PHP statement
Yes it is stored in a database. And I'm not sure if it goes through a function or not. How would I be able to tell? This is a shopping cart software that is fully open source.Is that information stored in a database? Does the entry go through a function that prevents html from being displayed as html?
Re: Displaying Html Code within a PHP statement
Maybe this can help you: get_html_translation_table()
But in any case better if you will understand why you have this result.
But in any case better if you will understand why you have this result.
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: Displaying Html Code within a PHP statement
Below is the .phtml file that is generating the output. The example you showed me seems like it is doing the reverse of what I am trying to do. Unless I'm not understanding it very well. I do not know too much php.
Code: Select all
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<div class="collateral-box attribute-specs">
<table cellspacing="0" class="data-table" id="product-attribute-specs-table">
<?php foreach ($_additional as $_data): ?>
<tr>
[color=#FF0000] <td class="label"><?php echo (nl2br($_data['label'])) ?></td>
<td class="data"><?php echo (nl2br($_data['value'])) ?></td>[/color] - generating output
</tr>
<?php endforeach; ?>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
</div>
<?php endif;?>Re: Displaying Html Code within a PHP statement
Sorry. Russian version of this article has this example:
In your example you need to replace last line to
Code: Select all
<?php
$trans = get_html_translation_table(HTML_ENTITIES);
$trans = array_flip($trans);
$original = strtr($encoded, $trans);
Code: Select all
$original = strtr($_data['label'], $trans);
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: Displaying Html Code within a PHP statement
Could you do me a favor?
Using these parameters, could you create what the new line would look like using my variables?
<td class="data"><?php echo (nl2br($_data['value'])) ?></td>
Thanks for your time.
Using these parameters, could you create what the new line would look like using my variables?
<td class="data"><?php echo (nl2br($_data['value'])) ?></td>
Thanks for your time.
Re: Displaying Html Code within a PHP statement
Code: Select all
<td class="data"><?php echo (nl2br(html_entity_decode($_data['value']))) ?></td>
-
Danielc1234
- Forum Newbie
- Posts: 18
- Joined: Tue Jul 29, 2008 11:55 am
Re: Displaying Html Code within a PHP statement
Ziq that WORKED!!!! Thanks so much. I would have never have figured that one out.