497 users online (0 members and 497 guests)  

  Results 1 to 3 of 3


  1. Replies: 4
  2. Displaying a table in Thunderbird    Forum: HTML Forum
    Replies: 1
  3. need help displaying results with links    Forum: PHP Forum
    Replies: 0
  4. Displaying pdfs    Forum: Graphics Forum
    Replies: 4
  5. Tags????????????    Forum: HTML Forum
    Replies: 4
  1. #1
    h_aida's Avatar
    New User

    Join Date
    Jan 2002

    Unhappy Help me with displaying HTML tags


    Can somebody help me with this problem... My main problem is I want to display HTML tags on a page without being interpreted by the browser as HTML tags. The text (which includes the tags) that I want to display is not hard-coded. Instead it is inserted into the database using form and displayed also in a form by retrieving it from the database.

    I know that one solution to this is to replace < and > symbols with their entity references: &lt; and &gt;
    So when inserting the text into the database, I replace all < and > with their entity references. It works when I retrieve the text from the database and display it on a page. But when I want to edit the text (the saved text is displayed in a text field in a form), it is automatically displayed with the < and > symbols, instead of the entity references. So I have to replace all the symbols again with their entity references. This is a tedious process especially when the text that I want to edit is quite long.

    So can anyone help me with this problem? Any help is very much appreciated.


  2. #2
    QuietDean's Avatar

    Join Date
    Oct 2000
    Bournemouth, UK


    Welcome to the forums!

    Thats a tricky one. I know how I would handle it -

    The html form is not going to display the correct code, so how about we play with whats inbetween the form and the database?

    I assume you are using some kind of server-side code to insert the form contents into the database. PHP, Perl, ASP whatever.

    I would set a small search and replace function in there to convert < and> to the correct code.

    In php, it would be ereg_replace(). Don't know enough about the others, but I guarantee they have a similar function.

    This is assuming, of course, that you have access to the server side script. If you don't, then you must be using another script to display the contents of the DB, so put the ereg in there instead.

    let me know if this helps.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Unregistered's Avatar

    Thumbs up

    <xmp>"text here"</xmp>

Tags for this Thread