Two questions:
1)
I created a database with a descripton field. Inside this field I also include some HTML tags for links and to format some text. The Database encodes the HTML files, for instance a break <br /> tag is written as <br />
My problem is that when I view the data in a browser it places the HTML tags with the text. Is there a way to read the html tags so links and text are displayed in elegant way?
2)
I Also trying to bind a date field and display it in a table. but it needs to be converted from Julian Day count to Gregorian date. Does anybody knows how to?
Thank you any feed back will be greatly appreciated. von
decoding HTML tags from a database into a php page
Moderator: General Moderators
Re: decoding HTML tags from a database into a php page
Use function htmlspecialchars_decode. If you have troubles with that, use following scriptvongurdy wrote:1)
I created a database with a descripton field. Inside this field I also include some HTML tags for links and to format some text. The Database encodes the HTML files, for instance a break <br /> tag is written as <br />
My problem is that when I view the data in a browser it places the HTML tags with the text. Is there a way to read the html tags so links and text are displayed in elegant way?
Code: Select all
<?php
function htmlEncode($html) {
$trans = get_html_translation_table(HTML_ENTITIES);
$s = array_keys($trans);
$t = array_values($trans);
$text = str_replace($t,$s,$html);
return $text;
}
echo htmlEncode("Text<br>Text"); // returns Text<br>Text
?>Re: decoding HTML tags from a database into a php page
NOmeR1 it worked nicely, Thank you so much.