Solved

How to display HTML code from database using PHP and preventing the browser from interpreting the code.

Posted on 2007-03-20
4
1,093 Views
Last Modified: 2012-05-05
I have html code contained in a database (MySQL) of code maintenance information.  I want to be able to display the html code without having the code interpreted.

Is there a php function to encode the html so that it displays as text (showing all of the tags)?  Or is there an HTML tag set that stops the interpretation of content between tags?

Thanks
0
Comment
Question by:ttheimer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:steelseth12
ID: 18759830
try

<textarea cols="90" rows="30">
<? echo $html ?>

</textare>
0
 

Author Comment

by:ttheimer
ID: 18760007
Textarea produces a fixed-size input field.  Not a good fit for displaying database contents (essentially an on-screen report).
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 125 total points
ID: 18760371
try

print htmlentities($html);
0
 

Author Comment

by:ttheimer
ID: 18760696
That's what I needed!  The report now prints cleanly.  Thanks.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question