<? PHP
$ Conn = mysql_connect ('localhost', 'root', 'wy ')
Or die ('Connection failed: '. mysql_error ());
// Select a data table
If (mysql_select_db ('mynews', $ conn ))
{
Echo: the database is selected! '.' <P> ';
}
Else
{
Echo 'database selection failed! '. Mysql_error ().' <p> ';
}
@ Header ("Content-Type: text/html; charset = UTF-8 ");
Mysql_query ("set names 'utf8 '");
$ Fp = fopen ("temp.html", "R ");
$ Content = fread ($ FP, filesize ("temp.html "));
$ Onepage = 2;
$ SQL = "select ID from News ";
$ Query = mysql_query ($ SQL );
$ Num = mysql_num_rows ($ query );
$ Allpages = Ceil ($ num/$ onepage );
For ($ I = 0; $ I <$ allpages; $ I ++ ){
If ($ I = 0 ){
$ Indexpath = "index.html ";
} Else {
$ Indexpath = "index _". $ I. ". html ";
}
$ Start = $ I * $ onepage;
$ List = '';
$ SQL _for_page = "select * from news limit $ start, $ onepage ";
$ Result = mysql_query ($ SQL _for_page );
While ($ ROW = mysql_fetch_array ($ result ))
{
$ List. = 'uid = '. $ row ['id']. $ row ['title'].' <br> ';
}
$ Content1 = str_replace ("{articletable}", $ list. $ I, $ content );
// Pagination
$ List1 = '';
For ($ J = 0; $ j <$ allpages; $ J ++ ){
If ($ J = 0 ){
$ List1. = '<a href = "index.html"> page'. $ J. '</a> | ';
} Else {
$ List1. = "<a href = 'index _". $ J. ". html"> page ". $ J." </a> | ";
}
}
$ Content2 = str_replace ("{mune}", $ list1, $ content1 );
If (is_file ($ indexpath )){
@ Unlink ($ indexpath); // delete a file if it already exists
}
$ Handle = fopen ($ indexpath, "W"); // open the file pointer and create a file
/*
Check whether the file is created and writable.
*/
If (! Is_writable ($ indexpath )){
Echo "file:". $ indexpath. "cannot be written. Check its attributes and try again! "; // Modify it to echo
}
If (! Fwrite ($ handle, $ content2) {// write information to the file
Echo "Generating File". $ indexpath. "failed! "; // Modify it to echo
}
Fclose ($ handle); // close the pointer
}
Fclose ($ FP );
Die ("generation of paging files is complete. If the generation is incomplete, check the File Permission System and generate a new one! ");
?>
Temp.html
{Title}
This Is A {file} file's templets
{ articletable}
paging {mune}