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?