PHP master, I just learned PHP, in the generation of static paging encountered a point about the problem, that is, the issue of the page, hoping to give a beautiful full page flip code, thank you

Source: Internet
Author: User
Big Brother PHP Master, little brother I just learned PHP, in the generation of static paging encountered a problem, is the issue of paging, I hope you can give a beautiful full page flip code, thank you!




<title>PHP generation static HTML Paging implementation method</title>




$conn =mysql_connect (' localhost ', ' root ', ' 123456 ')
Or Die (' Connection failed: '. mysql_error ());
Select data table
if (mysql_select_db (' BBS ', $conn))
{
Echo ' Select Database Success! '.'

';

}
Else
{
Echo ' Database selection failed! '. Mysql_error (). '

';
}
@header ("content-type:text/html; Charset=utf-8 ");
mysql_query ("SET NAMES ' UTF8 '");

$fp = fopen ("moban/temp.html", "R");
$content = Fread ($fp, FileSize ("moban/temp.html"));
$onepage = 2;
$sql = "SELECT ID from Message";
$query = mysql_query ($sql);
$num = mysql_num_rows ($query);
$allpages = Ceil ($num/$onepage);
$filedir = "News_1";
if (!is_dir ($filedir)) {
If it does not exist, establish
mkdir ($filedir, 0777);
}
for ($i = 0; $i < $allpages; $i + +) {
if ($i = = 0) {
$indexpath = "$filedir/index.html";
} else {
$indexpath = "$filedir/index_". $i. ". HTML ";
}
$start = $i * $onepage;
$list = ";
$sql _for_page = "SELECT * from Message limit $start, $onepage";
$result =mysql_query ($sql _for_page);
while ($row =mysql_fetch_array ($result))
{
$list. = $row [' id ']. " ". $row [' title ']. '
'. $row [' content ']. '
';
}
$content 1 = str_replace ("{articletable}", $list. $i, $content);
Page out
$list 1 = ";
for ($j = 0; $j < $allpages; $j + +) {
if ($j = = 0) {
$list 1. = ' $j '. ' page | ';
} else {
$list 1. = "No.". $j. " Page | ";
}
}
$content 2 = Str_replace ("{mune}", $list 1, $content 1);

if (Is_file ($indexpath)) {
@unlink ($indexpath); If the file already exists, delete the
}
$handle = fopen ($indexpath, "w"); Open file pointer, create file
/*
Check if the file is created and writable
*/
if (!is_writable ($indexpath)) {
echo "File:". $indexpath. " Not writable, please check its properties and try again! "; Modify to Echo
}
if (!fwrite ($handle, $content 2)) {//write information to file
echo "Generate file". $indexpath. " Failed! "; Modify to Echo
}
Fclose ($handle); Close pointer
}
Fclose ($fp);d IE ("raw page file completion, such as incomplete, please check the file permissions system and regenerate!") ");
?>



------Solution--------------------
Paging is not a paging class with many threads? It's not right?

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