1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Text to HTML on the Fly

Discussion in 'Programming' started by BayouBengal, Jun 9, 2005.

  1. #1
    I have an archive of txt files. I have an application that will bring up a menu listing those text files. When the user clicks on one of the links in their browser, it retrieves the txt file from the archive and displays it to the user. I would like to convert that txt file to html format, so when the user clicks on the link it brings up an html file, instead of the txt file. I have found numerous stand-alone applications that will convert txt to html, and vice versa, but am unable to locate any scripts that will accomplish this or similar. Looking for cgi, javascript, or asp. Any assistance is appreciated.
     
    BayouBengal, Jun 9, 2005 IP
  2. North Carolina SEO

    North Carolina SEO Well-Known Member

    Messages:
    1,327
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    105
    #2
    Have you looked into scripts that would use the txt file as an include?

    Whether asp, php or use of javascript there seem to be plenty of ways to perform the display of the txt wrapped within a file dynamically passing the txt file name as a parameter.
     
    North Carolina SEO, Jun 9, 2005 IP
  3. tresman

    tresman Well-Known Member

    Messages:
    235
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    138
    #3
    why don't you do something like:

    file.php?retrieve=thetextfile.txt

    
    <html>
    <head>
    <!-- PUT SOME METAS HERE IF YOU WANT -->
    <!-- Following we use the name of the file as title -->
    <title><? echo $retrieve ?> </title> 
    </head>
    <body>
    
    <!-- and now we include the content of the text file in to the body -->
    
    <? include $retrieve; ?>
    
    </body>
    </html>
    
    Code (markup):
    Don't expect this to work, I really do not know about php, but its the main idea to work on it.
     
    tresman, Jun 9, 2005 IP
  4. BayouBengal

    BayouBengal Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you for your responses. Please let me clarify. I DO need to format the text. We already have an html page with an include. What we're trying to do is actually format the text into tables, tr's etc. I apologize for not including this info at first.
     
    BayouBengal, Jun 9, 2005 IP
  5. tresman

    tresman Well-Known Member

    Messages:
    235
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    138
    #5
    Then should you post more info on how the text files are written, how is the data structured...
     
    tresman, Jun 9, 2005 IP
  6. BayouBengal

    BayouBengal Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The reports are .txt files that include a title, and tables with 4-6 columns listing name of product, quantity, description, etc. I'm not sure if this is what you meant
     
    BayouBengal, Jun 9, 2005 IP
  7. Trance-formation

    Trance-formation Peon

    Messages:
    598
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if they are text files, they don't include tables...

    but it seems to me that you want php with a couple of file reading options

    readfile () returns the contents of the file
    file() returns an array with each new line of the file as an element of the array which can be useful
    explode( string separator, string string [, int limit] ) will take a string and break it into an array according to a string seperator.... useful for turning comma seperated files into arrays

    (I'm sure ASP would have equivalent functions)
     
    Trance-formation, Jun 9, 2005 IP