PHP generates HTML static page, phphtml static page
Function:
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.
Example:
-
- if ($_get[pg]==') {
- $AA = 1;
- }else{
- $AA =$_GET[PG];
- }
- Include ("admin/conn.php");
- Require_once ("page.php");
- $result =mysql_query ("select * from 2carsell");
- $totle =mysql_num_rows ($result);
- $pagelist = $_get[t];
- if ($_get[t]==') {
- $pagelist =' $ ';
- }else{
- $pagelist =$_get[t];
- }
- $pager = New Pager ($totle,$pagelist);
- $datastat ="Total ". $pager->countall. " Bar, generate each time . $pager->countlist. " Create a ". $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 2carsell the ORDER by ID DESC limit $limitFrom, $pagelist");
- ?>
- "FONT-SIZE:14PX;" > echo $aa?> page Generation: echo $datastat?>
-
- PHP generates static pages
- Www.jbxue.com
- Print" "; </span></li><li><span class= "keyword" >while (<span class= "VARs" > $datauser =mysql_ Fetch_array (<span class= "VARs" > $result)) {</span></span></span></li><li> < /li><li><span class= "VARs" > $iid =<span class= "VARs" > $datauser [ID]; </span></span></li><li><span class= "VARs" > $html = <span class= "func" >file_get_ Contents (<span class= "string" > "/moban.php?id=". <span class= "VARs" > $iid. <span class= "string" > "") ; </span></span></span></span></span></li><li><span class= "VARs" > $sql =<span class= "string" > "SELECT * from 2carsell where id= $iid"; </span></span></li><li><span class= "VARs" > $data =mysql_fetch_array (mysql_query ( <span class= "VARs" > $sql)); </span></span></li><li><span class= "VARs" > $path =<span class= "func" >date (< span class= "string" > "Ym", <span class= "VARs" > $data [putdate]); </span></span></span></span></li><li><span class= "VARs" > $testdir =< Span class= "string" > "html/". <span class= "VARs" > $path; </span></span></span></li><li><span class= "keyword" >if (<span class= "func" >file_exists (<span class= "VARs" > $testdir)): </span></span></span></li><li ><span class= "keyword" >else: </span></li><li><span class= "func" >mkdir (<span class= "VARs" > $testdir, 0777); </span></span></li><li><span class= "func" >echo <span class= "string" > "Directory" .< Span class= "VARs" > $testdir. <span class= "string" > "Created successfully! <br> "; </span></span></span></span></li><li><span class= "keyword" >endif; </span></li><li> </li><li><span class= "VARs" > $fileName = <span class= "string" > "html/$path/sell_$iid.html"; </span></span></li><li> </li><li><span class= "comment" >//use write mode to open $ FileName </span></li><li><span class= "keyword" >if (!<span class= "VARs" > $handle = < Span class= "func" >fopen (<span class= "VARs" > $filename, <span class= "string" > ' W ')) {</span></ Span></span></span></span></li><li>print <span class= "string" > "Cannot open File $ FileName "; </span></li><li><span class= "func" >exit; </span></li><li>} </li><li> </li><li><span class= "keyword" >if ( <span class= "func" >is_writable (<span class= "VARs" > $filename)) {</span></span></span ></li><li> </li><li><span class= "comment" >//writes $html to our open file. </span></li><li><span class= "keyword" >if (!fwrite(<span class= "VARs" > $handle, <span class= "VARs" > $html)) {</span></span></span></li><li>print <span class= "string" > "Cannot write to file $filename" ; </span></li><li><span class= "func" >exit; </span></li><li>} </li><li> </li><li>print <span class= "string" > " File $filename updated successfully! \n\r "; </span></li><li> </li><li>fclose (<span class= "VARs" > $handle); </span></li><li> </li><li>} <span class= "keyword" >else {</span></li ><li>print <span class= "string" > "File $filename not writable"; </span></li><li>} </li><li>?> </li><li><? }?> </li><li>
- "FONT-SIZE=12PX" > echo $datastat." "?>
-
- $AA =$aa +1;
- if ($aa >$bb) {
- Echo ' Congratulations, all pages generated! ';
- echo "";
- }else{
- echo "";
- }
- ?>
http://www.bkjia.com/PHPjc/1080760.html www.bkjia.com true http://www.bkjia.com/PHPjc/1080760.html techarticle PHP generates HTML static pages, phphtml static page functionality: 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 ...