PHP generate HTML static page instance code _ PHP Tutorial

Source: Internet
Author: User
PHP generates HTML static page instance code. Developed for the cd2sc.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 developed for the function of the cd2sc.com website. 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.

The code is as follows:


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". $ 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 ");
?>

The Page generation ..



Print" "; <BR> while ($ datauser = mysql_fetch_array ($ result) {<br> $ iid = $ datauser [id]; <BR> $ html = file_get_contents ("/moban. php? Id = ". $ iid. ""); <BR> $ SQL = "select * from 2 carw.where id = $ iid"; <BR> $ data = mysql_fetch_array (mysql_query ($ SQL )); <BR> $ path = date ("Ym", $ data [PutDate]); <BR> $ testdir = "html /". $ path; <BR> if (file_exists ($ testdir): <BR> else: <BR> mkdir ($ testdir, 0777); <BR> echo "directory ". $ testdir. "created successfully! <Br> "; <BR> endif; <br> <BR> $ filename =" html/$ path/sell_policiid.html "; <br> // enable $ filename in write Mode <BR> if (! $ Handle = fopen ($ filename, 'w') {<BR> print "the file $ filename cannot be opened"; <BR> exit; <BR >}< br> <br> if (is_writable ($ filename) {<br> // write $ html to the open file. <BR> if (! Fwrite ($ handle, $ html) {<BR> print "cannot be written to the file $ filename"; <BR> exit; <BR >}< br> <br> print "file $ filename updated successfully! \ N \ r "; <br> fclose ($ handle); <br> <br >}else {<BR> print" file $ filename cannot be written "; <BR >}< BR >?> <BR> <? }?> <BR>









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