Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 348827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:24:04+00:00 2026-05-12T11:24:04+00:00

I am trying to append to a log file, using HTML tables format for

  • 0

I am trying to append to a log file, using HTML tables format for each incident. However, there is one difficulty which I am not sure how to solve. Here’s a static output of the HTML

<table>
  <tr><td> .... </td>
  </tr>

 <!-- new log entry should enter here -->

  </table>
</html>

The question is how I can quickly insert log entries into the table quickly without messing up the HTML, preferably using the least amount of processing? I know I can load in the entire file, use a templating solution, and rewrite the file but that may be slow (the log files could grow fast quickly!).

So I am looking for the usual open file for append, and somehow write after the last row, but before the tag.

Any suggestions?

PS. I know most browser would render the HMTL if I leave out the tag at the end, but I am curious to see if there could be an ideal solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:24:04+00:00Added an answer on May 12, 2026 at 11:24 am

    I’d suggest creating the log file with just the table rows, then including it in the file with the needed header and footer.

    So you would write to ‘log.html’, but view ‘log.php’ which would be:

    <html>
      <head>
      </head>
      <body>
        <table>
          <?php include('log.html') ?>
        </table>
      </body>
    </html>
    

    Of course, perhaps a better way would be to store the log data without html (in a flat file or database) then generate the view on demand. But for what you’re looking for, the above should work.

    If it all must be in a static file, you could use

    bool ftruncate ( resource $handle , int $size )
    

    to remove the last line of the file. Just make sure you know how long the ‘footer’ is. Here’s some example code that might work for you.

    $footer = "</table></html>";
    $file = fopen($log_file, 'rw');
    ftruncate($file, strlen($footer));
    fseek($file, 0, SEEK_END);
    fputs($file, $log);
    fputs($file, $footer);
    fclose($file);
    

    Here’s the ftruncate function documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 166k
  • Answers 166k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are several simple 3D engines for both silverlight (eg.… May 12, 2026 at 1:24 pm
  • Editorial Team
    Editorial Team added an answer NSFileManager *manager = [NSFileManager defaultManager]; NSArray *fileList = [manager directoryContentsAtPath:documentsDirectory];… May 12, 2026 at 1:24 pm
  • Editorial Team
    Editorial Team added an answer Use ISQL. See http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.utility/html/utility/utility10.htm for the complete reference. Specifically, you're… May 12, 2026 at 1:24 pm

Related Questions

I am trying to create an XML file, but the XML file needs to
I am quite new to C# (I had an RS-232 problem recently) and am
My first delve into working with JSON data. I have a bit of experience
Is it not possible to append to an ObjectOutputStream ? I am trying to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.