A copy of Oso PHP Forum program (one) 1th/2 page _php instance

Source: Internet
Author: User
Tags datetime
I often use the Oso forum, personal feeling is very good, so imitate the interface of Oso compiled a program, share with everyone.
Program consists of three parts, that is, display the theme information, display forum information, add forum information, theme and forum content using master-slave table relationship.
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 ', ' number of pages ', ' 20 '); /* Adjust this parameter to modify the number of rows per page * *

Program 1:mainforum.php
<link rel= "STYLESHEET" type= "Text/css" href= "Fp_zhangcg.css" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Microsoft Theme" content= "None" >
<meta name= "Microsoft Border" content= "None" >
<title> Forum </title>

<body bgcolor= "#C0C0C0" background= "BackColor. GIF ">

?
Include ("C:mydbheader.inc");
?>

<table width= "100%" border= "0" >
<tr class= "Text" >
&LT;TD width= "50%" > <div align= "left" > Current location: Home--Forum </div> </td>
&LT;TD width= "20%" > <div align= "center" > </div> </td>
&LT;TD width= "10%" > <div align= "Center" >
<a href= "addmember.php" target=_blank> member registration </A></div> </td>
&LT;TD width= "10%" > <div align= "center" > Forum Search </div> </td>
&LT;TD width= "10%" > <div align= "center" > </div> </td>
</table>


?
$DBH = mysql_connect (' localhost:3306 ', ' 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 ', ' pages ', ')", $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 ' <table width= "100%" border= "0" > ";
print ' <tr class= ' text ' > ';
print ' <td width= ' 15% ' > </td> ';
print ' <td width= ' 35% ' > <div align= ' left ' > ';
Print "Number of topics:". $rcount. " Number of posts: ". $rcon _count;
print ' <td width= ' 35% ' > <div align= ' right ' > ';
print ' <a href= "addforum.php?theme_id=0" target= "_top" ></a > ';
print ' <td width= ' 15% ' > </td> ';
print ' </td></table> ';


$pages =ceil ($rcount/$pageline); $pages variable now contains the required number of pages

if (empty ($offset)) {
$offset = 1;
$curline = 0;
} else
$curline = ($offset-1) * $pageline;
To print a table header
print ' <table width= "100%" border= "0" > ";
print ' <tr class= "text" > <td width= "50%" > <div align= "center" >;
if ($offset <> 1) {//If the offset is 0, do not display the link to the previous page
$newoffset = $offset-1;
Print "<a href= ' $PHP _self?offset= $newoffset ' > Prev </a>";
} else {
Print "Previous page";
Print "";
}
Calculate the total number of pages required
$pages =ceil ($rcount/$pageline); $pages variable now contains the required number of pages
Current 1/2 page 12 Next read the full text

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.