Home Backend Development PHP Tutorial Forum imitating OSO (1)_PHP tutorial

Forum imitating OSO (1)_PHP tutorial

Jul 21, 2016 pm 04:02 PM
one imitate of forum this


I believe that everyone who has been to OSO will be deeply impressed by OSO’s forum. This forum is excellent in every aspect. Do you want to have such a beautiful forum on your homepage? In fact, it is not too complicated. Below we will only imitate the OSO forum from some basic parts.
Since I only use this forum as my message board, my forum can be regarded as a simple match of the OSO forum. 1. In my forum, users can only speak after logging in. The user's ID is stored in a cookie variable called "cookie_user". 2. My forum does not have sub-forums. 3. I do not count the number of clicks on a topic. , 4. I have not designed the icon in front of each topic in the OSO forum to indicate whether there are new posts. 5. I have not considered the optional topic arrangement and display time period provided by the OSO forum. 6. There is no statistics on members’ posting points. 7. There is no function for moderators to manage the forum. 8. There is no function for editing posts. We will touch on how to extend these eight functions based on my program at the end.
First is the design of a database. In fact, a forum involves two data tables. Let’s temporarily name them user and guestbook. The user table stores the information of registered users. The creation statement is as follows:
create table my_user(
user_id char(12) not null,/*username*/
user_password varchar(8) not null,/*user password*/
PRIMARY KEY (user_id)
)
The guestbook stores the post content.The creation content is as follows:
CREATE TABLE guestbook (
id bigint DEFAULT '0' NOT NULL auto_increment,/*speak id, auto-increment field*/
name varchar(12) NOT NULL,/*topic creation Person*/
type tinyint NOT NULL,/*type 0-reply; 1-main post*/
theme varchar(50) NULL,/*theme*/
content blob NOT NULL,/*content */
icon tinyint NOT NULL,/*emoticon*/
time_open datetime not NULL,/*topic creation time*/
time_close datetime not NULL,/*last reply time*/
answer_count int not null,/*number of replies*/
answer_name varchar(12) not null,/*last replyer*/
main_id bigint null,/*main post id*/
PRIMARY KEY (id) /**/
);
The program contains five php source codes: connect.inc.php, faq.php, read.php, post.php, reply.php, post_end.php
connect.inc.php: (used to connect to the database)
$dbhostname = "localhost";
$dbusername = "";
$dbpassword = "";
$ dbName = "";
MYSQL_CONNECT($dbhostname, $dbusername, $dbpassword) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database "); " ;


                                                                  
src="mypic/x.js">

Only members can speak here

;TABLE align=center border=0 cellPadding=4 cellSpacing=1 width=100% class=body_br >
                                                                                                       $res = mysql_query($query);
$row = mysql_fetch_row($res);
$total =$row[0];
                                                                                1;
         echo $total; /TD>
                                              td width=1%>
                                                                           $res = mysql_query($query);  
                     $row = mysql_fetch_row($res);  
                     echo $row[0];
                     ?>
            
            href="post.php">            border=0  
          src="mypic/post.gif">
      
          主  
            题

                      color=#ffffff>创建人
                      color=#ffffff>回复
                      color=#ffffff>回复人
                      color=#ffffff>最后回复时间
function TdBackColor() {
  static $ColorStr;
  if ($ColorStr=="#ededed") {
    $ColorStr="#dedede";
  } else {
    $ColorStr="#ededed";
  }
  return($ColorStr);
}
if (!$page) $page=1;
$ysylimit=($page-1)*20;
$query = "select theme,answer_count,id,name,answer_name,DATE_FORMAT(time_close,'%Y-%m-%d') as mydate from guestbook where type=1 order by time_close DESC limit ".$ysylimit.",20 ";  
$res = mysql_query($query);  
for ($i=0; $i<20; $i++) {
  $row = @mysql_fetch_array($res);  
  if(!$row) break;
  $ColorStr=TdBackColor();
  echo "".$row['theme'];
    echo "
";
    if ($row['answer_count']>5)
    {echo "   echo "class=small color=#666666>  分页:";
    for ($j=1;$j<=($row['answer_count']-1)/5+1;$j++) echo "";  
    }
    echo "";  
    echo "";  
   echo $row['name']."";
  $ii=$row['answer_count']-1;
  echo "".$ii."";
   echo "";  
  echo $row['answer_name']."";
  echo "".$row['mydate']."";}
?>

      



分页
$page1=$page-1;
$page2=$page+1;
if ($page==1) echo "首页 前页 ";  
else echo "
首页 前页 ";  
if ($page==$totalpage) echo "后页 尾页 ";  
else echo "后页 尾页 ";  
?>
当前页:  转到第 页  
            



www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316720.htmlTechArticle相信每一个到过OSO的人都会对OSO的论坛留下极深的印象,这个论坛无论从那一方面来说都是比较出色的。你想不想你的主页也有这么一个漂...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) Dec 31, 2023 pm 05:15 PM

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

What is discuz forum? What is discuz forum? Jul 10, 2023 am 11:03 AM

The discuz forum is an online forum software, also known as BBS. It is a program system used to establish forum communities on the Internet. Zhiyo's powerful forum software can help users build a professional and complete forum community, and can implement a variety of functions, such as building user registration, logging in, viewing topics, publishing posts, making comments, setting up moderators, etc. Allow users to easily manage and maintain the forum community.

The first choice for CS players: recommended computer configuration The first choice for CS players: recommended computer configuration Jan 02, 2024 pm 04:26 PM

1. Processor When choosing a computer configuration, the processor is one of the most important components. For playing games like CS, the performance of the processor directly affects the smoothness and response speed of the game. It is recommended to choose Intel Core i5 or i7 series processors because they have powerful multi-core processing capabilities and high frequencies, and can easily cope with the high requirements of CS. 2. Graphics card Graphics card is one of the important factors in game performance. For shooting games such as CS, the performance of the graphics card directly affects the clarity and smoothness of the game screen. It is recommended to choose NVIDIA GeForce GTX series or AMD Radeon RX series graphics cards. They have excellent graphics processing capabilities and high frame rate output, and can provide a better gaming experience. 3. Memory power

The way the robot imitates my expression makes people feel a little scared The way the robot imitates my expression makes people feel a little scared Apr 09, 2023 am 10:11 AM

Usually, the main function of a robot is to complete some simple operating tasks. We hope that the robot can imitate people and make its capabilities as close as possible to human levels. Whether it is Xiaomi's CyberOne or Tesla's Optimus, people are mainly concerned about its number of mechanical joints, control algorithm and walking speed. However, in this field, some people are exploring more imaginative directions: Now, there is a robot that can imitate real human expressions to the extreme: try taking a selfie first. From "disgust" to "surprise", everything can be completely synchronized: This robot is called Ameca, and it is a weird expression. In addition to imitating, it can also make many small expressions when looking in the mirror, making it look very much like a real person. Ameca "pretends" to see the mirror for the first time,

Digital audio output interface on the motherboard-SPDIF OUT Digital audio output interface on the motherboard-SPDIF OUT Jan 14, 2024 pm 04:42 PM

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

Glodon Software's computer configuration recommendations; Glodon Software's computer configuration requirements Glodon Software's computer configuration recommendations; Glodon Software's computer configuration requirements Jan 01, 2024 pm 12:52 PM

Glodon Software is a software company focusing on the field of building informatization. Its products are widely used in all aspects of architectural design, construction, and operation. Due to the complex functions and large data volume of Glodon software, it requires high computer configuration. This article will elaborate on the computer configuration recommendations of Glodon Software from many aspects to help readers choose a suitable computer configuration processor. Glodon Software requires a large amount of data calculation and processing when performing architectural design, simulation and other operations. Therefore, the requirements for the processor are higher. It is recommended to choose a multi-core, high-frequency processor, such as Intel i7 series or AMD Ryzen series. These processors have strong computing power and multi-thread processing capabilities, and can better meet the needs of Glodon software. Memory Memory is affecting computing

Discuz Forum Permission Management: Read Permission Setting Guide Discuz Forum Permission Management: Read Permission Setting Guide Mar 10, 2024 pm 05:33 PM

Discuz forum permission management: Read the permission setting guide In Discuz forum management, permission setting is a crucial part. Among them, the setting of reading permissions is particularly important, as it determines the scope of content that different users can see in the forum. This article will introduce in detail the reading permission settings of the Discuz forum and how to flexibly configure it for different needs. 1. Basic concepts of reading permissions In the Discuz forum, reading permissions mainly include the following concepts that need to be understood: Default reading permissions: Default after new user registration

What are the php forums? What are the php forums? Jul 25, 2023 am 11:12 AM

PHP forums include: 1. PHP Forum, the forum section of the PHP official website, which is an important platform for communication among PHP developers; 2. phphub, a well-known PHP technology community in China and one of the largest PHP technology forums in China; 3. Laracasts, an online learning platform for the Laravel framework; 4. Reddit PHP, a world-renowned social news aggregation website; 5. SitePoint, a comprehensive technology community that provides everything from web design to development.

See all articles