View Full Version : static html with php help!
why not
07-18-2008, 10:24 PM
hi ! how to automatic generate a html file with php ( MYSQL database ) ? with this method rescue server and speeding load page . NOTE and EXAMPLE : add any data in mysql = generate html static page auto . thanks regards .
Jesdisciple
07-19-2008, 02:21 PM
Erm, you mean you want to put the whole HTML source in the database? I think that would slow your site down rather than speed it up.
why not
07-19-2008, 08:22 PM
no ! my mean generate html page static when post data in mysql and save in php page ! so example : movabletype Or Vbuletin . in this script show data in html static page .
Jesdisciple
07-19-2008, 09:00 PM
Can you post a link to an example page?
By "static HTML page," do you mean a page with a .html extension? The only way I know to include dynamic content in such a page when the user visits it (given that the server isn't so strangely configured as to parse it) is AJAX... But I don't know how to use POST data with that.
Or are you asking how to modify a static page from PHP? Like, the user visits a PHP page which changes an HTML page based on POST data sent to the first one?
Does anyone else have a guess at what he means?
GarethMc
07-21-2008, 08:41 AM
I think what he is trying to accomplish is to store HTML generated from PHP scripts into a static HTML file on the fileserver to call later.
We had to do this recently for a client due to high processing times on a very large database at the end of the month...
Why Not: What you are looking for is PHP's buffer functions. In your PHP script place a ob_start() command before ANY HTML is sent to the browser. Then at the end of the script you can do $html_content = ob_get_contents(); . The variable $html_content will now contain all the HTML that was generated by your PHP script. You could then store that in a static file on your server using the file system functions fopen() and fwrite(), or even just echo it to display in the users browser as well.
Links to these functions are:
ob_start() (http://www.php.net/ob_start)
ob_get_contents() (http://www.php.net/manual/en/function.ob-get-contents.php)
fopen() (http://www.php.net/manual/en/function.fopen.php)
fwrite() (http://www.php.net/manual/en/function.fwrite.php)
Hope this helps you :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.