I often use oso forums, and I personally feel quite good. I have compiled a program on the oso interface to share it with you. The program consists of three parts: Display the topic information, display the forum information, and add Forum Information. The relationship between the topic and the Forum content is in the master-slave table. The table structure is as follows: droptablefr_t_forumtitle; createtablefr_t_forumtitle (idin I often use oso forums. I personally feel pretty good, so I compiled a program on the oso interface to share it with you.
The program consists of three parts: Display the topic information, display the forum information, and add Forum Information. The relationship between the topic and the Forum content is in the master-slave table.
The table structure is as follows:
Drop table fr_t_forumtitle;
Create table fr_t_forumtitle (
Id integer,
State varchar (1 ),
Readcount integer,
Replycount integer,
Title varchar (100 ),
Createman varchar (20 ),
Replyman varchar (20 ),
Replytime datetime );
Drop table fr_t_forumcontent;
Create table fr_t_forumcontent (
Id integer,
Replyman varchar (20 ),
Replytime datetime,
Replyemail varchar (100 ),
Replyhttp varchar (100 ),
Replyface smallint,
Content text );
Drop table fr_t_parameter;
Create table fr_t_parameter (
Code varchar (10 ),
Name varchar (40 ),
Content varchar (10 ));
Insert into fr_t_parameter (code, name, content) values ('pageline ', 'page', '20');/* adjust this parameter to modify the number of lines per page */
Program 1: mainforum. php
Forum
Include ("c: mydbheader. inc ");
?>
Current location: Homepage-Forum |
|
Member registration |
Forum search |
|
$ Dbh = mysql_connect ('localhost: 100', 'root ','');
Mysql_select_db ('test ');
$ Res = mysql_query ("SELECT content FROM fr_t_parameter where code = 'pageline '", $ dbh );
$ Row = mysql_fetch_array ($ res );
Global $ pageline;
$ Pageline = $ row ["content"];
If (empty ($ pageline )){
$ Res = mysql_query ("insert into fr_t_parameter (code, name, content) values ('pageline ', 'number of pages', '20')", $ dbh );
$ Row = mysql_fetch_array ($ res );
$ Pageline = 20;
}
$ Res = mysql_query ("select count (*) AS rcnt FROM fr_t_forumtitle", $ dbh );
$ Row = mysql_fetch_array ($ res );
$ Rcount = $ row ["rcnt"];
$ Res = mysql_query ("select count (*) AS rcnt_con FROM fr_t_forumcontent", $ dbh );
$ Row = mysql_fetch_array ($ res );
$ Rcon_count = $ row ["rcnt_con"];
Print'
';Print'
';Print'
| ';Print'
'; Print "number of topics:". $ rcount. "number of posts:". $ rcon_count; Print' |
'; Print ''; Print' |
| ';Print'
';
$ Pages = ceil ($ rcount/$ pageline); // The $ pages variable now contains the required page number
If (empty ($ offset )){
$ Offset = 1;
$ Curline = 0;
} Else
$ Curline = ($ offset-1) * $ pageline;
// Print the header
Print'
';Print'
'; If ($ offset <> 1) {// if the offset is 0, the link to the previous page is not displayed. $ Newoffset = $ offset-1; Print "previous page "; } Else { Print "previous page "; Print ""; } // Calculate the total number of required pages $ Pages = ceil ($ rcount/$ pageline); // The $ pages variable now contains the required page number For ($ I = 1; $ I <= $ pages; $ I ){ $ Temps = "". $ I .""; Print $ temps; Print ""; } // Check whether it is the last page If ($ pages! = 0 & $ offset! = $ Pages ){ $ Newoffset = $ offset 1; Print "next page "; } Else print "next page "; Print' | ';Print'
'; Print "current page:". $ offset. "total". $ pages. "page "; Print' | ';Print"
";
// Process detailed information
Print'
';Print'
';Print'
New | ';Print'
Click | ';Print'
Topic | ';Print'
Created | ';Print'
Reply | ';Print'
Last modification time | ';Print'
Reply | ';Print'
';$ Query = 'SELECT id, state, readcount, title, createman, replycount, replytime, replymanFrom fr_t_forumtitle order by replytime desc LIMIT '. $ curline.', 20 ';$ Res = mysql_query ($ query, $ dbh );// $ Li_rownum = mysql_num_rows ($ res );// For ($ I = 1; $ I <= $ li_rownum; $ I ){// $ Row = mysql_fetch_row ($ res );While ($ row = mysql_fetch_array ($ res )){Print'
';Print'
'. $ Row ["state"].' | ';Print'
'. $ Row ["readcount"].' | ';$ Tempstr = "". $ row ['title']. "";Print'
'. $ Tempstr .' | ';// Print'
'. $ Row ["title"].' | ';Print'
'. $ Row ["createman"].' | ';Print'
'. $ Row ["replycount"].' | ';$ Temptime = substr ($ row ["replytime"], 5, 11 );Print'
'. $ Temptime .' | ';Print'
'. $ Row ["replyman"].' | ';Print'
';}Print"
";
// Print the end of the table
Print'
';Print'
'; If ($ offset <> 1) {// if the offset is 0, the link to the previous page is not displayed. $ Newoffset = $ offset-1; Print "previous page "; } Else { Print "previous page "; Print ""; } // Calculate the total number of required pages For ($ I = 1; $ I <= $ pages; $ I ){ $ Temps = "". $ I .""; Print $ temps; Print ""; } // Check whether it is the last page If ($ pages! = 0 & $ offset! = $ Pages ){ $ Newoffset = $ offset 1; Print "next page "; } Else print "next page "; Print' | ';Print'
'; Print "current page:". $ offset. "total". $ pages. "page "; Print' | ';Print"
";
// End of the printed table
?>
Include ("c: mydbfooter. inc ");
?>
[This article is copyrighted by the author zhangcg and osuo. if you need to reprint it, please indicate the author and its source]