Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Saving DB output to an HTML file

( #30060=categorized question: print w/ replies, xml ) Need Help??
Contributed by rodry on Aug 29, 2000 at 04:26 UTC
Q&A  > CGI programming


Description:

I am working on a web site that stores Resume information (along with photos) of whoever wants to subscribe to the web site.

I decided that for better performance I should save the generated pages into HTML text files and then link directly to it thru the URL instead of sending queries to the DB.

I know how to write to a text file a few lines of DB generated output, but not a page that is generated from more than three separate queries, like the ones from the website I just mentioned.

I need some directions as to how to attack this particular problem.

Thanks in advance...

Answer: Saving DB output to an HTML file
contributed by vaevictus

Writing a text file from multiple query's is not any different than writing it from one.

Well... you can always open a file for appending... so depending on your particular format,

//query number 1 $current_resume=$result->{'CustomerID'}; // or the like open (FILE,">>$current_resume"); // open the file based on the curren +t user in APPEND MODE print FILE $header_information; // title and so on print FILE $query_one_data; close FILE; //IF NECESSARY //query number 2 open (FILE,">>$current_resume"); //IF CLOSED previously. print FILE $query_two_data; close FILE; // etc... for as many queries that you need.
I may be way off target, but that's what the reply button is for.
Answer: Saving DB output to an HTML file
contributed by arturo

I would check out using templates of some sort, such as HTML::Template and/or CGI::FastTemplate.
The concept's fairly simple, you create an HTML file which has 'placeholders' in it, and you can fill in the data however you like; you can even put loops in the placeholders, so you can put 1-n entries in under (say) past experience. What you get, basically, is a common look and feel for the resumes, but each will have the user's personal info in it.
I'd like to suggest, too, that you just do it on the fly. Saves space, and also makes sure that the user has the most up-to-date version, synched to her info in the DB. I'd only go with caching if you have a very high-volume site or an unreliable DB connection.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (10)
    As of 2014-09-19 17:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (143 votes), past polls