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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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> <? } ?> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.