Re: HOW: save php-database query-results as html ...
| From: | bill | Date: | Sat, 12 Aug 2000 13:58:24 +0000 |
| Subject: | Re: HOW: save php-database query-results as html ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11458@lists.php.net to get a copy of this message | ||
Save the file before you display the results to the browser.
<?php
$headerstuff="<HTML><HEAD><TITLE>Query
Result</TITLE></HEAD><BODY>";
$footerstuff="</BODY></HTML>";
// do your query here
// save your results as a string variable.
$results="<P>blah blah blah";
//now save your file
$fp = fopen("myfile.html", "w");
$stringtowrite=$headerstuff . $results . $footerstuff;
$good= fwrite($fp, $stringtowrite);
//and echo the same results to the browser
echo $stringtowrite;
?>
kind regards,
bill
Helmut Ott wrote:
> I want to reduce the database-load by saving the result of a php-driven database-query-result
> to html:
>
> E.g. we made a database query and received the result list.
> If you click on an entry the specific records page is shown.
> In case this record does not change very often it makes sense to store this records page as
> html.
>
> My problem: I dont know how to make a script that does not only display the record(as a result
> of a database-query) but also save this result-page as html. Because once the rsult is shown the
> php-script was finished before (the result page is shown when the php-script has been worked
> through).
>
> Any idea around?
>
> Helmut