PHP static learning notes 5: simple news system v1.1

Source: Internet
Author: User
Tags newsfile
This is my learning notes written in the static process of my PHP Technology page. I hope this will help you. 1. Basic Idea (1) when we add or update news, we create or update html pages synchronously to solve the real-time problem and put the generated html file path in the database; (2) Design a template file through the Template

This is my learning notes written in the static process of my PHP Technology page. I hope this will help you. 1. Basic Idea (1) when we add or update news, we create or update html pages synchronously to solve the real-time problem and put the generated html file path in the database; (2) Design a template file through the Template

This is my learning notes written in the static process of my PHP Technology page. I hope this will help you.


1. Basic Ideas

(1) When we add or update news, we create or update html pages synchronously to solve the real-time problem and put the generated html file path in the database;

(2) Design a template file and create a static page through the template;

(3) access html static pages each time;

2. The database follows the above database structure. It is best to clear the data

3. Code

News_list.php (News list page)

 SqlHelper. class. php $ conn = mysql_connect ("localhost", "root", "root"); if (! $ Conn) {die ("connection failed");} mysql_select_db ("static_pages_news", $ conn); mysql_query ("set names utf8 "); $ SQL = "select * from news order by id"; $ res = mysql_query ($ SQL); header ("content-type: text/html; charset = UTF-8 "); echo "News list"; echo "Add news
 "; Echo"
 
 
  
  
"; Echo"
  
  "; While ($ row = mysql_fetch_assoc ($ res) {echo" 
   ";} Echo" 
  
Id Title View news Modify news
{$ Row ['id']} {$ Row ['title']} View Details Modify details
"; Mysql_free_result ($ res); mysql_close ($ conn);?>

Add_news.html (Add news page)

 Add news

Update_newsui.php (modify the news page)

 "; Echo""; Echo"
"; Echo"
"; Echo"{$ Row ['content']}
"; Echo""; Echo"
"; Echo" ";}Else {echo" the news you are viewing does not exist ";}?>

NewsAction. php (ADD and modify the page for processing news requests)

 

Template. tpl (the template of the news presentation page)

 
 % Title %
 
 
 
 % Title %
 
%content%
Back to list

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.