View Single Post
Old 07-21-2005, 16:00   #4 (permalink)
arccos
Civilians

 
Default Re: Inserting HTML code in an HTML page



GreyWyvern wrote:
> 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


In addition to this suggesstion, you may want to use the <pre> tag to
keep all white space formatting (new lines and the such) the same as in
the original code.

Arccos
---

http://www.landoflyrics.com - Land Of Lyrics

  Reply With Quote
 
Page generated in 0.58952 seconds with 14 queries