View Full Version : static html with php help!

eric float
07-19-2008, 12:14 AM
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 .

07-19-2008, 02:24 AM
The only way to automatically launch a php page is with a cron/scheduling job which is a part of the system the site is hosted on.
There is also what I refer to as 'poor mans cron' which is the same thing as a cron job but relies on a user to load you're pages for you. Its somewhat complex to set up so I won't go into that here. Instead, check you're server for cron jobs, chances are fairly high its supported - its quite popular now.

eric float
07-19-2008, 07:20 AM
my server support cron job ! and my localhost in windows worked with Cron For Windows/ (http://www.cronforwindows.com/) . i need to any script for this idea . thanks

07-19-2008, 08:35 AM
Oh I see.
This really depends on what you are storing in you're database. If its complete code (like templates) than you can write a script that scans each entry in the database and iterates through the records, and using file handling (http://ca3.php.net/manual/en/ref.filesystem.php) you can create files and write the data to them. Look into the fopen with w+b, fwrite and fclose. Note if you have PHP5 available you can also use file_put_contents which takes care of the open, write and close for you.

This shouldn't be too terrible of a task, you're looking at probably 20-50 lines of code. Pair it up with a cronjob (or you're windows variation) and your all done. Try some things out, read from a database first for you're records, than write data to a file. After that combine them together. Shouldn't take you too long to do.
Come back if you have any problems with how to do specific things!

eric float
07-19-2008, 10:26 PM
Oops !? my example : movabletype Or vbulletin ! this script generate html static auto with php or perl . way out is html page ( with out mod_rewirte apache ) How to ? Any Idea for this ?