Jump to content

generate a fixed .htm from a dynamic .php everytime the page is loaded


johnwayne77

Recommended Posts

I am trying to generate a static .htm page from a dynamic .php page everytime that page is loaded.

 

for example:

 

my scripts runs this url to display the result:

 

http://www.imobconsulting.ro/tv/main.php?program=ers&action=Afiseaza+program

 

and i would like somehow to export the displayed result to a .htm file, for example:

 

http://www.imobconsulting.ro/tv/html_pages/ers.htm

 

any ideas?

Link to comment
Share on other sites

like inside the main.php or the program=ers page to add something like:

 

export to html_pages/ers.htm

 

location (header: html_pages/ers.htm);

 

but I am stuck with the export to thing

 

[ reply for orio:

 

i am having trouble with writing the results to a htm page I guess as creating the results is done successfully ]

Link to comment
Share on other sites

Here is part of a newsletter thing i wrote a while ago, i'm sure you can adjust it to your needs.

Read comments


<?php

// prepare to save a html version of news.php
// make sure you already have a blank html page to duplicate from
$source_html_doc = "../newsletter/archive/blank.html";
$today = date(dmY);
$new_blank_html_doc = "../newsletter/archive/news_".$today."html";
copy($source_html_doc, $new_blank_html_doc)or die('Could not copy required file');

// start getting the generated contents of news.php
ob_start();
require("news.php"); // or run php contents here instead
$body_news = ob_get_contents();

// write a html version of it as archive
$html_change = fopen ($new_blank_html_doc, 'w');
fwrite ($html_change, $body_news);
fclose ($html_change);

// END ob_start
ob_end_clean();

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.