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.
Developed for the jbxue.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.
Example:
Php code
- <? 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 = '20140901 ';
- } Else {
- $ Pagelist = $ _ GET [t];
- }
- $ Pager = new Pager ($ totle, $ pagelist );
- $ Datastat = "Total <B> ". $ pager-> countall. "</B>, generated each time <B> ". $ pager-> countlist. "</B>, which must be generated <B> ". $ pager-> page. "</B> 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 ");
- ?>
- <Center> <div style = "font-size: 14px;"> <B> NO. <font color = red> <? Echo $ aa?> </Font> page generation... <? Echo $ datastat?> </B> </div> <br>
- <?
- // Php generates a static page
- // Www.jbxue.com
- Print "<center> <textarea name = textarea class = textarea style = 'width: 520px; height: 455px '> ";
- While ($ datauser = mysql_fetch_array ($ result )){
- $ Iid = $ datauser [id];
- $ Html = file_get_contents ("/moban. php? Id = ". $ iid ."");
- $ SQL = "select * from 2 cartid 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_$iid.html ";
- // Enable $ filename in write mode
- 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 "cannot be written to file $ filename ";
- Exit;
- }
- Print "File $ filename updated successfully! \ N \ r ";
- Fclose ($ handle );
- } Else {
- Print "File $ filename cannot be written ";
- }
- ?>
- <? }?>
- </Textarea>
- <Br>
- <Div style = "font-size = 12px"> <? Echo $ datastat. ""?> </Div> <br>
- <?
- $ Aa = $ aa + 1;
- If ($ aa> $ bb ){
- Echo '<font color = blue> congratulations, all pages have been generated! </Font> ';
- Echo "<script> alert ('All documents have been generated/updated! ') </Script> ";
- } Else {
- Echo "<Script> window. location = 'make. php? T = $ pagelist & pg = $ aa '; </script> ";
- }
- ?>