johnadamson Posted November 6, 2007 Share Posted November 6, 2007 Dear all, I would like to display html from a database on a webpage, obviously as formatted. e.g. The row in the database is <p>This is some <b>bold</b> text and some <i>italic</i> text.</p> But when I try and print this onto my page is displays <p>This is some <b>bold</b> text and some <i>italic</i> text.</p> Does anyone know how I can display the formatted text as This is some bold text and some italic text. Hope you can help. Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/ Share on other sites More sharing options...
pocobueno1388 Posted November 6, 2007 Share Posted November 6, 2007 You need to decode the html entities. You can use this function when displaying it html_entity_decode() - http://us2.php.net/html_entity_decode Sorry if I misunderstood your question, hopefully that is what you want. Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/#findComment-385861 Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 Why dont you just ECHO or PRINT it from PHP? Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/#findComment-385864 Share on other sites More sharing options...
johnadamson Posted November 6, 2007 Author Share Posted November 6, 2007 pocobueno1388 that worked an absolute treat!! FANTASTIC!! Thanks for all your help. revraz I tried using ECHO or PRINT originally because I thought that would work, but just got <p>This is some <b>bold</b> text and some <i>italic</i> text.</p> Thanks for your replies. Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/#findComment-385869 Share on other sites More sharing options...
atlanta Posted November 6, 2007 Share Posted November 6, 2007 The way i do it is escape out of php and echo the html inside of making php work to display the content.. ex. <?php if($variable == "yes") { ?> <b>Bold</b><i>text</i> <? } ?> Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/#findComment-385871 Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 Interesting, I've never had an issue myself doing it with Echo's. pocobueno1388 that worked an absolute treat!! FANTASTIC!! Thanks for all your help. revraz I tried using ECHO or PRINT originally because I thought that would work, but just got <p>This is some <b>bold</b> text and some <i>italic</i> text.</p> Thanks for your replies. Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/#findComment-385874 Share on other sites More sharing options...
pocobueno1388 Posted November 6, 2007 Share Posted November 6, 2007 Interesting, I've never had an issue myself doing it with Echo's. pocobueno1388 that worked an absolute treat!! FANTASTIC!! Thanks for all your help. revraz I tried using ECHO or PRINT originally because I thought that would work, but just got <p>This is some <b>bold</b> text and some <i>italic</i> text.</p> Thanks for your replies. It's because they change the HTML to entities before inserting the information into the database. So when they printed it to the screen straight out of the database, it was still in entity form. So all they had to do was use the function I showed them to decode the entities back to HTML tags. Link to comment https://forums.phpfreaks.com/topic/76236-solved-display-html/#findComment-385878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.