Php method for generating HTML static pages, phphtml static pages
Generates HTML static pages from PHP and stores them in a directory created with the name of the year and month.
Read all data batch generation, all generated after the popup prompt.
You can specify the number of batches to be generated, no more than 800 is recommended, or the execution speed will be problematic.
For the Jbxue.com website features developed, the code for my original, generation speed generally.
(For well-known reasons, the data field name involved in the database has been changed and the part of the parameter filter has been removed for code clarity)
Description: The original dynamic address is moban.php?id=1, the post-generated address is html/200808/sell_1.html. Page.php is a paging program, published in this blog.
Page usage, save this code as make.php, using the method for the browser to access the number of make.php?t= &pg= page, such as make.php?t=300&pg=2, that is, each time 300 data generated, starting from the 2nd page of the data list, That is, skip the previous 300 bars. If you access make.php directly without any parameters, the default is 200 per build, starting from the first page.
Complete Example:
". $pager->countall."Bar, each time you generate". $pager->countlist."Bar, total build required". $pager->page."//Data Statistics $BB = $pager->page; $pagenav = $pager->backstr. $pager->thestr. $pager->nextstr; $limitFrom = $pagelist * ($pager->pg-1); $result =mysql_query ("SELECT * from 2carsell the ORDER by ID DESC limit $limitFrom, $pagelist"); ?>
Page generated in the first time:
<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 2carsell 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 "Catalog". $testdir. " Create success! <br> "; endif $filename = "html/$path/sell_$iid.html"; Use write mode to open $filename if (! $handle = fopen ($filename, ' W ')) {print "Cannot open file $filename"; Exit } if (Is_writable ($filename)) {//writes $html to our open file. if (!fwrite ($handle, $html)) {print "Cannot write to file $filename"; Exit } print "File $filename updated successfully! \n\r "; Fclose ($handle); } else {print "File $filename not writable"; }?> <? }?></textarea>
$BB) {echo ' Congratulations, all pages generated! '; echo ""; }else{echo ""; }?>
http://www.bkjia.com/PHPjc/1072324.html www.bkjia.com true http://www.bkjia.com/PHPjc/1072324.html techarticle PHP generates HTML static pages in a way that phphtml static pages from PHP to generate HTML static pages and store them in a directory created with the name of the year and month. Read all data batch generation, all ...