PHP產生HTML靜態頁面執行個體代碼

來源:互聯網
上載者:User
為cd2sc.com網站功能而開發,代碼為本人原創,產生速度一般。
(出於眾所周知的原因,涉及到資料庫的資料欄位名稱做了改動,並且為了代碼明晰去掉了參數過濾的部分)

說明:原動態地址為 moban.php?id=1 ,產生後地址為 html/200808/sell_1.html 。page.php為分頁程式,本部落格中有發布。
頁面使用方式,將本代碼儲存為make.php,使用方法為瀏覽器訪問 make.php?t=數量&pg=頁面;例如 make.php?t=300&pg=2,即每次產生300條資料,從資料列表第2頁開始產生,即跳過前面300條。如果不加任何參數,直接存取make.php,則預設每次產生200條,從第一頁開始產生。

<?php 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='200'; }else{ $pagelist=$_GET[t]; } $pager = new Pager($totle,$pagelist); $datastat=" 共 <b>".$pager->countall."</b> 條,每次產生 <b>".$pager->countlist."</b> 條,共需產生 <b>".$pager->page."</b> 次";//資料統計 $bb=$pager->page; $pagenav=$pager->backstr.$pager->thestr.$pager->nextstr; $limitFrom = $pagelist*($pager->pg-1); $result=mysql_query("select * from 2carsell ORDER BY id DESC limit $limitFrom,$pagelist"); ?> <center><div style="font-size:14px;"><b>第 <font color=red><?echo $aa?></font > 次頁面產生中..<? echo $datastat?></b></div><br> <? 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 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 "目錄".$testdir."建立成功!<br>"; endif; $filename = "html/$path/sell_$iid.html"; // 使用寫入模式開啟$filename if (!$handle = fopen($filename, 'w')) { print "不能開啟檔案 $filename"; exit; } if (is_writable($filename)) { // 將$html寫入到我們開啟的檔案中。 if (!fwrite($handle, $html)) { print "不能寫入到檔案 $filename"; exit; } print "檔案 $filename 更新成功!\n\r"; fclose($handle); } else { print "檔案 $filename 不可寫"; } ?> <? }?> </textarea> <br><br> <div style="font-size=12px"><? echo $datastat."  "?></div><br><br> <? $aa=$aa+1; if($aa>$bb){ echo '<font color=blue>恭喜,所有頁面產生完畢!</font>'; echo "<script>alert('所有文檔產生/更新完畢!')</script>"; }else{ echo "<Script> window.location='make.php?t=$pagelist&pg=$aa'; </script>"; } ?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.