PHP generates HTML static page instance code _php instance

Source: Internet
Author: User
For the Cd2sc.com website function development, the code for my original, the production speed is general.
(for well-known reasons, the data field name involved in the database has been altered and the parameter filtering part has been removed for clarity of the code)

Note: The original dynamic address is moban.php?id=1, and the post generated address is html/200808/sell_1.html. Page.php is a paging program, published in this blog.
How the page is used, save this code as make.php, and use the method to access the make.php?t= number &pg= pages for the browser; For example, make.php?t=300&pg=2, which generates 300 data at a time, starts at page 2nd of the list of data. Skip the front 300. If you access make.php directly without any arguments, 200 is generated by default each time, starting at the first page.
Copy Code code as follows:

<?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 = "Total <b>". $pager->countall. " </b>, each generation <b> ". $pager->countlist." </b>, a total of Generation <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 2carsell ORDER by ID DESC limit $limitFrom, $pagelist");
?>
<center><div style= "FONT-SIZE:14PX;" ><b> <font color=red><?echo $aa? ></font > Secondary page generation ... ? 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 "Directory". $testdir. " Create success! <br> ";
endif


$filename = "html/$path/sell_$iid.html";

Open $filename using Write mode
if (! $handle = fopen ($filename, ' W ')) {
Print "Cannot open file $filename";
Exit
}

if (is_writable ($filename)) {

Write the $html to the file we opened.
if (!fwrite ($handle, $html)) {
Print "cannot be written to the file $filename";
Exit
}

Print "File $filename update successful! \n\r ";

Fclose ($handle);

} else {
Print "File $filename not writable";
}
?>
? }?>
</textarea>
<br><br>



<div style= "font-size=12px" &GT;&LT;? echo $datastat. ""? ></div><br><br>
?
$AA = $aa +1;
if ($aa > $bb) {
Echo ' <font color=blue> Congratulations, all pages generated! </font> ';
echo "<script>alert (' All document Generation/update completed!") ') </script>;
}else{
echo "<Script> window.location= ' make.php?t= $pagelist &pg= $aa '; </script> ";
}
?>

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.