Home php教程 php手册 一个简洁的多级别论坛

一个简洁的多级别论坛

Jun 13, 2016 pm 12:38 PM
h code example exist quick implement of concise level forum run speed

本论坛总共用了不到200行代码,执行速度相当快。运行例子在:http://www.hnpts.ha.cn/forum
MYSQL数据库:yxforum
+-------+--------------+------+-----+---------+----------------+  
| Field | Type         | Null | Key | Default | Extra          |  
+-------+--------------+------+-----+---------+----------------+  
| id    | int(11)      |      | PRI | 0       | auto_increment |  
| dt    | datetime     | YES  |     | NULL    |                |  
| tp    | varchar(255) | YES  |     | NULL    |                |  
| ct    | text         | YES  |     | NULL    |                |  
| fl    | int(11)      | YES  |     | NULL    |                |  
| ip    | varchar(20)  | YES  |     | NULL    |                |  
| un    | varchar(50)  | YES  |     | NULL    |                |  
| em    | varchar(60)  | YES  |     | NULL    |                |  
| num   | int(11)      | YES  |     | NULL    |                |  
+-------+--------------+------+-----+---------+----------------+  

index.php:  

  

  
  
  
  
$m=mysql_connect("localhost","××××","××××");  
  mysql_select_db("××××",$m);  
?>  

$hf_fl=$fl;  
$q="select * from yxforum where id=".$fl;  
$mr=mysql_query($q,$m);  
$ra=mysql_fetch_row($mr);  
?>  


  
?>  
%s) ",$ra[7],$ra[6]);?>  

  
$alltt=$ra[2];  
   $lastid=$ra[4];   
   print("
".$ra[3]."
");  
   print("
跟随主题:");  
   }   

$q="select * from yxforum where fl=".$fl." order by dt desc";  
  if ($p=="") $p=0;  
  $mr=mysql_query($q,$m);  
  $f=mysql_num_fields($mr);  

$ra=mysql_fetch_row($mr);  
$i=0; $p1=$p*15; /*跳过指定的页数对应的行*/  
while ($i    {$i++;  
     $ra=mysql_fetch_row($mr);  
     if (! $ra) break;}  

    
?>  
  
    
       
        
  
  $x[0]="ffffcc";$x[1]="DEEFFF";$i=1;  
  while  ($ra)  /*显示目前的主题*/  
    {$ys_c=$i%2;  
     print("");  
     $ra=mysql_fetch_row($mr);  
     $i++;   
     if ($i>15) break;     
  }   

?>  
最新回应时间  
      
发表人  
      
主题  
      
回应数  
     
".$ra[1]);  
     print("
".$ra[6]."");  
     print("
");  
     printf("%s",$ra[0],$ra[2]);  
     print("
".$ra[8]);  
     print("
  
  
  
  
$alllines=mysql_affected_rows($m);  
$pages=$alllines/15;  
if ($pages-intval($pages)!=0) $pages=intval($pages)+1;  
    else $pages=intval($pages);  
print("共".$pages."页 第".($p+1)."页 ");  

if ($p>0) {printf("首页 ",$hf_fl);  
           printf("上一页 ",$hf_fl,$p-1);}  
if ($ra)  {printf("下一页 ",$hf_fl,$p+1);  
           printf("末页 ",$hf_fl,$pages-1);}  
?>指定第页  
  
  
上一级 ",$lastid);  
                  print("最高级
");}  
?>  
  
  
  
  
姓名:   
      
    
  
    Email:   
      
    
  
    标题(必填):  
     >  
      
      
     
  
    正文(必填):
  

     
      
  
  

  
自用论坛程序0.25版 设计工具:PHP+MYSQL
  
古钺青剑 制作
逍遥飞狐多媒体作坊 2000
  
  
  
  



addnew.php:  

$m=mysql_connect("localhost","×××","×××××");  
  mysql_select_db("×××××",$m);  
  $zw=ereg_replace("   $zw=ereg_replace(">",">",$zw);  
$zw=ereg_replace("n","
",$zw);  
   $zw=ereg_replace(" "," ",$zw);  
   $tt=ereg_replace("   $tt=ereg_replace(">",">",$tt);  
     if ($nm=="") $nm="无名宝";  
  if ($em=="") {$nm.="  $err=strlen($tt)*strlen($zw);  
  if ($err==0)   
     $msg="不要偷懒嘛!把表格填完再提交不迟。";  
  else {$q="insert into yxforum (dt,tp,ct,fl,ip,un,em,num) values"  
         ."(now(),"".$tt."","".$zw."",".$fl.","".$REMOTE_ADDR."","".$nm."","".$em."",0)";  
        mysql_query($q,$m);  

        $q="select num,fl from yxforum where id=".$fl;  
        $fl_a=$fl;  
        do { $mr=mysql_query($q,$m);  
             $ra=mysql_fetch_row($mr);  
             $num=$ra[0]+1;  
             $q="update yxforum set dt=now(),num=".$num." where id=".$fl;  
             $fl=$ra[1];  
             mysql_query($q,$m);  
             $q="select num,fl from yxforum where id=".$fl;  
            } while ($fl>0);    

        
   $msg="你的意见已经成功提交!";  
        }  
?>  
  
  
  
  

  
系统将在3秒钟以后自动返回。如果不能返回或者你着急,请按&p=>这里  
 
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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 execute .sh file in Linux system? How to execute .sh file in Linux system? Mar 14, 2024 pm 06:42 PM

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

GE universal remote codes program on any device GE universal remote codes program on any device Mar 02, 2024 pm 01:58 PM

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

How to use Copilot to generate code How to use Copilot to generate code Mar 23, 2024 am 10:41 AM

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button

How to run m-file in matlab - Tutorial on running m-file in matlab How to run m-file in matlab - Tutorial on running m-file in matlab Mar 04, 2024 pm 02:13 PM

Do you know how to run m files in matlab? Below, the editor will bring you a tutorial on how to run m files in matlab. I hope it will be helpful to you. Let’s learn with the editor! 1. First open the matlab software and select the upper left "Open" the corner, as shown in the picture below. 2. Then select the m file to be run and open it, as shown in the figure below. 3. Press F5 in the window to run the program, as shown in the figure below. 4. We can view the running results in the command line window and workspace, as shown in the figure below. 5. You can also run the file by clicking "Run" directly, as shown in the figure below. 6. Finally, you can view the running results of the m file in the command line window and workspace, as shown in the figure below. The above is the matlab method that the editor brought to you

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

In-depth interpretation: Why is Laravel as slow as a snail? In-depth interpretation: Why is Laravel as slow as a snail? Mar 07, 2024 am 09:54 AM

Laravel is a popular PHP development framework, but it is sometimes criticized for being as slow as a snail. What exactly causes Laravel's unsatisfactory speed? This article will provide an in-depth explanation of the reasons why Laravel is as slow as a snail from multiple aspects, and combine it with specific code examples to help readers gain a deeper understanding of this problem. 1. ORM query performance issues In Laravel, ORM (Object Relational Mapping) is a very powerful feature that allows

Where to open win8 running Where to open win8 running Mar 20, 2024 pm 03:46 PM

There are three ways to open the Run dialog: using the Win + R shortcut, through the search function, or by typing "Run" directly in the Start screen.

Create and run Linux ".a" files Create and run Linux ".a" files Mar 20, 2024 pm 04:46 PM

Working with files in the Linux operating system requires the use of various commands and techniques that enable developers to efficiently create and execute files, code, programs, scripts, and other things. In the Linux environment, files with the extension ".a" have great importance as static libraries. These libraries play an important role in software development, allowing developers to efficiently manage and share common functionality across multiple programs. For effective software development in a Linux environment, it is crucial to understand how to create and run ".a" files. This article will introduce how to comprehensively install and configure the Linux ".a" file. Let's explore the definition, purpose, structure, and methods of creating and executing the Linux ".a" file. What is L

See all articles