Home Backend Development PHP Tutorial Example (Smarty+FCKeditor News System)_PHP Tutorial

Example (Smarty+FCKeditor News System)_PHP Tutorial

Jul 21, 2016 pm 03:58 PM
index.php host code content copy Example document news yes of system

The following is the content of the main file index.php:

Copy the code The code is as follows:

require('./global.php') ;
require('./smarty/libs/Smarty.class.php');
require('./mysql.php');
require('./FCKeditor/fckeditor.php') ;
$action=$_REQUEST['action'];
//Define a function to call FCK
function editor($input_name, $input_value)
{
global $smarty;
$editor = new FCKeditor($input_name) ;
$editor->BasePath = "./FCKeditor/";//Specify the editor path

$editor->ToolbarSet = " Default";//The editor toolbar has Basic (basic tools), Default (all tools) selection
$editor->Width = "100%";
$editor->Height = "320" ;
$editor->Value = $input_value;
$editor->Config['AutoDetectLanguage'] = true ;
$editor->Config['DefaultLanguage'] = 'en' ; //Language
$FCKeditor = $editor->CreateHtml();

$smarty->assign("editor", $FCKeditor);//Specify area
}

switch ($action){

case 'addnewsview':

$smarty= new Smarty();
$smarty->template_dir = './template';
$smarty->compile_dir = './smarty/templates_c';
$smarty->assign('page_title','New News');
$smarty->assign('actionvalue ','addnews');
editor('content','');//Call the editor and define the text domain name as content (corresponding to $_REQUEST['content'] in addnews below
$ smarty->display('addnews.htm');
break;

case 'addnews':
$title=$_REQUEST['title'];
$content=$ _REQUEST['content'];
$db=new mysql();
$button=$_REQUEST['Submit'];

if(empty($title) || empty($ content)){
echo "Please fill in the form! ";
    }else{                                                      ,'admin','$title','$content',NOW())";
             $db->query_exec($sql);"; 
        } 
break; 

case 'editnewsview': 
        $smarty= new Smarty(); 
        $smarty->template_dir = './template'; 
        $smarty->compile_dir = './smarty/templates_c'; 
        $smarty->assign('page_title','修改新闻'); 
        $smarty->assign('actionvalue','addnews'); 
        $id=$_REQUEST['id']; 

        $query="select * from news where id=$id"; 
        $db=new mysql(); 
        $result = $db->query_exec($query); 
        $rs = $result-> fetch_assoc(); 

        $smarty->assign('title',$rs['title']); 
        //$smarty->assign('content',$rs['content']); 
        $smarty->assign('actionvalue','editnews'); 
        $smarty->assign('id',$rs['id']); 
        editor('content',$rs['content']); 
        $smarty->display('addnews.htm'); 
break; 

case 'editnews': 
        $title=$_REQUEST['title']; 
        $content=$_REQUEST['content']; 
        $id=$_REQUEST['id']; 

        $button=$_REQUEST['Submit']; 
        $db=new mysql(); 
        if ($button=='提交'){ 
                $sql="update news set title='$title',content='$content',date=NOW() where id=$id"; 
                $db->query_exec($sql); 
        echo "操作成功!"; 
        } 
break; 

case 'delnews': 
        $db=new mysql(); 
        if ($checkbox!="" or count($checkbox)!=0) { 
                for ($i=0;$i                        $db->query_exec("delete from news where id='$checkbox[$i]'"); 
                } 
        } 
        echo "操作成功!"; 
break; 

default: 
        $smarty= new Smarty(); 
        $smarty->template_dir = './template'; 
        $smarty->compile_dir = './smarty/templates_c'; 
        $smarty->assign('page_title','新闻管理'); 
        $smarty->assign('actionvalue','delnews'); 

        $query="select * from news"; 
        $db=new mysql(); 
        $result = $db->query_exec($query); 

        while ($rs = $result-> fetch_assoc()) { 
                $array[]= array("id"=>$rs['id'], "title"=>$rs['title'],"date"=>$rs['date']);  
                $smarty->assign('news',$array); 
        } 

        $smarty->display('index.htm'); 


?> 

以下是模板文件index.htm的内容 
nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
 
 
 
{$page_title} 

 

 

新闻管理

 

 
 
   
     
     
   
   
     
   
系统管理
 
       
         
           
           
           
         
                {section name=news loop=$news}  
         
           
           
           
         
                {/section} 
      
标题日期选择
{$news[news].title}{$news[news].date}
 
      

 
         
       
          

 
    
 
 

 

 
 
 

以下是添加新闻的模板文件addnews.htm 
nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
 
 
 
 
{$page_title} 
 

 

新闻管理登陆 

 

 
 
   
     
     
   
   
     
   
系统管理
 
      

标题 
           

 
      

内容:

 
      

{$editor}

 
      

 
          
                 
                  
                

 
    
 

        
添加新闻
 
 
 


注:数据库已经在附件里面,先新建一个名为new的数据库,再把表导入
本系统用户名:admin    密码:admin
打包下载
Example (Smarty+FCKeditor News System)_PHP Tutorial 下载此文件

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/317500.htmlTechArticle以下是主文件index.php的内容: 复制代码 代码如下: metahttp-equiv="Content-Type"content="text/html;charset=utf-8" ?php require('./global.php'); require('./smarty/libs/...
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)

CUDA's universal matrix multiplication: from entry to proficiency! CUDA's universal matrix multiplication: from entry to proficiency! Mar 25, 2024 pm 12:30 PM

General Matrix Multiplication (GEMM) is a vital part of many applications and algorithms, and is also one of the important indicators for evaluating computer hardware performance. In-depth research and optimization of the implementation of GEMM can help us better understand high-performance computing and the relationship between software and hardware systems. In computer science, effective optimization of GEMM can increase computing speed and save resources, which is crucial to improving the overall performance of a computer system. An in-depth understanding of the working principle and optimization method of GEMM will help us better utilize the potential of modern computing hardware and provide more efficient solutions for various complex computing tasks. By optimizing the performance of GEMM

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Jul 30, 2024 pm 02:17 PM

On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Jun 02, 2024 pm 02:58 PM

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

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

Detailed explanation of the role of .ibd files in MySQL and related precautions Detailed explanation of the role of .ibd files in MySQL and related precautions Mar 15, 2024 am 08:00 AM

Detailed explanation of the role of .ibd files in MySQL and related precautions MySQL is a popular relational database management system, and the data in the database is stored in different files. Among them, the .ibd file is a data file in the InnoDB storage engine, used to store data and indexes in tables. This article will provide a detailed analysis of the role of the .ibd file in MySQL and provide relevant code examples to help readers better understand. 1. The role of .ibd files: storing data: .ibd files are InnoDB storage

Differences and similarities of cmd commands in Linux and Windows systems Differences and similarities of cmd commands in Linux and Windows systems Mar 15, 2024 am 08:12 AM

Linux and Windows are two common operating systems, representing the open source Linux system and the commercial Windows system respectively. In both operating systems, there is a command line interface for users to interact with the operating system. In Linux systems, users use the Shell command line, while in Windows systems, users use the cmd command line. The Shell command line in Linux system is a very powerful tool that can complete almost all system management tasks.

See all articles