View Single Post
Old 07-21-2005, 12:00   #2 (permalink)
GreyWyvern
Civilians

 
Default Re: Inserting HTML code in an HTML page

And lo, Francesky didst speak in alt.www.webmaster:

> HI,
>
> I am creating a little web site where I would like to publish articles.
> In
> the articles I usually display examples of programming languages code, or
> HTML code. Now, I get the articles by PHP and MySQL, or accessing a MySQL
> table using a PHP script. The article itself is a text type field in a
> database table. I insert text and code of the article, but, when I want
> to
> display it, for example, the HTML code of the example isn't showed, but
> there are only white lines. Now I would like something don'tlet this code
> be interpreted, as to be displayed as it is.


Before you display the HTML code in the field, just replace all < and >
with their respective HTML entities. Your sig says you know PHP so here's
a quick example:

$htmlString = str_replace(array("<", ">"), array("&lt;", "&gt;"),
$htmlString);

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollory that nothing is ridiculous.
- http://www.greywyvern.com - Orca Knowledgebase: Completely CSS styleable
Knowledgebase/FAQ system
  Reply With Quote
 
Page generated in 0.65052 seconds with 14 queries