Go Back   Trackpads Community > General Discussions > Computer and Technology > Web Design

Web Design Forums and discussions on webdesign

Web Design

Reply
 
LinkBack Thread Tools
Old 07-21-2005, 12:00   #1 (permalink)
Francesky
Civilians

 
Default Inserting HTML code in an HTML page

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.

Thanks

Franc

--
Teaching OnLine
Corsi online di programmazione
Php, Asp, C, C++, Visual Basic, Delphi
VBA per Access, Excel
Linux Shell Programming
------------------------------------
http://www.teachingonline.it

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-21-2005, 16:00   #3 (permalink)
Francesky
Civilians

 
Default Re: Inserting HTML code in an HTML page

> 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);
>


Well, it works, but I wanted something that in some part of the article
could have been disabled html interpretation, whele in other parts not.

For example, in the same article I put an img tag like this

<img src="/articles/art4/image_name1.png">

to diplay an image in the article.


Francesco



--
Teaching OnLine
Corsi online di programmazione
Php, Asp, C, C++, Visual Basic, Delphi
VBA per Access, Excel
Linux Shell Programming
------------------------------------
http://www.teachingonline.it

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
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

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-22-2005, 04:00   #5 (permalink)
Francesky
Civilians

 
Default Re: Inserting HTML code in an HTML page


> sure, but these are different elements of your document and deserve a
> different treatment.


I think I need something like in Wiki, where one could use formatting tags
to insert various object, text, images, ecc.

Frank

--
Teaching OnLine
Corsi online di programmazione
Php, Asp, C, C++, Visual Basic, Delphi
VBA per Access, Excel
Linux Shell Programming
------------------------------------
http://www.teachingonline.it

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display html example code within html GitarJake Web Design 1 11-05-2004 16:00
Biologist needs Mac code or script to repeatedly write javaoutput from an html page to a static text file Michael Levin Microsoft Applications 14 07-23-2004 20:42
Biologist needs Mac code or script to repeatedly write javaoutput from an html page to a static text file Michael Levin Microsoft Applications 14 07-23-2004 20:25
Inserting a HTML table in a page Virgil Web Design 0 07-23-2004 15:04
displaying the HTML code in HTML Astra Web Design 3 07-08-2004 07:31


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 20:11.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.86245 seconds with 19 queries