Use PHP to generate HTML static pages, php static pages _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags month name
Use PHP to generate HTML static pages and php static pages. Use PHP to generate HTML static pages. use php static pages to generate HTML static pages from PHP and store them to directories created with year and month names. Read all data for batch generation, all generate HTML static pages using PHP, and php static pages

Generate an HTML static page from PHP and store it to the directory created with the year and month name.

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.

(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.

Complete instance:

<? Php if ($ _ GET [pg] = '') {$ aa = 1;} else {$ aa = $ _ GET [pg];} include ("admin/conn. php "); require_once (" page. php "); $ result = mysql_query (" select * from 2 cartid "); $ totle = mysql_num_rows ($ result); $ pagelist = $ _ GET [t]; if ($ _ GET [t] = '') {$ pagelist = '000000';} else {$ pagelist = $ _ GET [t];} $ pager = new Pager ($ totle, $ pagelist); $ datastat = "total". $ 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 ");?>
 
  

Number <? Echo $ aa?>Page generation... <? Echo $ datastat?>


<? // Php generates static page print" "; 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 ";}?> <? }?>

<? Echo $ datastat. ""?>



<? $ Aa = $ aa + 1; if ($ aa> $ 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.