A Forum program imitating oso

Source: Internet
Author: User
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'
';
Print "number of topics:". $ rcount. "number of posts:". $ rcon_count;
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' ';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 "current page:". $ offset. "total". $ pages. "page ";
Print'
";

// Process detailed information

Print'






























';Print' ';Print' ';Print' ';Print' ';Print' ';Print' ';Print' ';Print' ';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' ';Print' ';$ Tempstr = "". $ row ['title']. "";Print' ';// Print' ';Print' ';Print' ';$ Temptime = substr ($ row ["replytime"], 5, 11 );Print' ';Print' ';Print' ';}Print"
NewClickTopicCreatedReplyLast modification timeReply
'. $ Row ["state"].''. $ Row ["readcount"].''. $ Tempstr .''. $ Row ["title"].''. $ Row ["createman"].''. $ Row ["replycount"].''. $ Temptime .''. $ Row ["replyman"].'
";

// Print the end of the table
Print'


';Print' ';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 "current page:". $ offset. "total". $ pages. "page ";
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]

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.