PHP generates HTML static page instance code

Source: Internet
Author: User
This program is used to generate HTML static pages from PHP and store them to the directories created with the year and month names. Read all data for batch generation. a prompt is displayed after all data is generated. You can specify the number of batches generated. we recommend that you do not exceed 800. Otherwise, the execution speed may be faulty. Developed for the cd2sc.com website function, the code is self-generated and the generation speed is average.
(For a well-known reason, the data field name involved in the database has been changed, and the parameter filtering is removed for the sake of code clarity)

Note: The original dynamic address is moban. php? Id = 1. the generated URL is html/200808/sell_1.html. Page. php is a paging program, which has been released in this blog.
Page usage: save this code as make. php. how can I access make. php in a browser? T = quantity & pg = Page; for example, make. php? T = 300 & pg = 2, that is, 300 pieces of data are generated each time, starting from page 1 of the data list, that is, the first 2nd pieces are skipped. If you directly access make. php without adding any parameters, 200 entries are generated each time by default, starting from the first page.

 ". $ Pager-> countall ."Entries, generated each time". $ Pager-> countlist ."Items to be generated". $ Pager-> page ."Times "; // data statistics $ bb = $ pager-> page; $ pagenav = $ pager-> backstr. $ pager-> thestr. $ pager-> nextstr; $ limitFrom = $ pagelist * ($ pager-> PG-1); $ result = mysql_query ("select * from 2 carrentorder BY id DESC limit $ limitFrom, $ pagelist ");?>
 
  

The Page generation ..


"; While ($ datauser = mysql_fetch_array ($ result) {$ iid = $ datauser [id]; $ html = file_get_contents ("/moban. php? Id = ". $ iid. ""); $ SQL = "select * from 2 carw.where id = $ iid"; $ data = mysql_fetch_array (mysql_query ($ SQL )); $ path = date ("Ym", $ data [PutDate]); $ testdir = "html /". $ path; if (file_exists ($ testdir): else: mkdir ($ testdir, 0777); echo "directory ". $ testdir. "created successfully! <Br> "; endif; $ filename =" html/$ path/sell_policiid.html "; // enable $ filename if (! $ Handle = fopen ($ filename, 'w') {print "the file $ filename" cannot be opened; exit;} if (is_writable ($ filename )) {// write $ html into the open file. If (! Fwrite ($ handle, $ html) {print "the file $ filename"; exit;} "$ filename is successfully updated! \ N \ r "; fclose ($ handle);} else {print" file $ filename cannot be written ";}?> <? }?>



$ Bb) {echo 'Congratulations, all pages have been generated! '; Echo "script alert ('all documents have been generated/updated! ') Script ";} else {echo"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.