News classification input and display system

Source: Internet
Author: User
The system can enter the title, content, images, and related software. when displaying the content, the system determines whether the content is displayed based on whether there are images and related software. when opening the page, the system displays the latest article, click the directory to display the previous article. Create the channelimages and channelsoft directories and set the permission to 777. * ********************************* New the system can enter the title, content, images, and related software, the system determines whether to display the item based on whether there are images and related software. The latest article is displayed on the page, and the previous article is displayed by clicking the directory.
Create the channelimages and channelsoft directories and set the permission to 777.
*********************************
News table structure
*********************************
# Host: localhost Database: yourdb
#--------------------------------------------------------

#
# Table structure for table 'yourtable'
#

Create table news (
Id int (11) DEFAULT '0' not null auto_increment,
Kind varchar (16 ),
Title varchar (60 ),
Content text,
Pic varchar (30 ),
Timer datetime DEFAULT '2017-00-00 00:00:00 'not null,
Soft varchar (30 ),
Primary key (id ),
KEY timer (timer)
);

*********************************
News input file: insert.htm
*********************************


News input






*********************************
End of insert.htm
*********************************

*********************************
Insert. php
*********************************
$ Day = date ("md ");
If ($ pic! = "None "){
$ Picname = $ day. $ pic_name;
Copy ($ pic, "channelimages/$ picname ");
Unlink ($ pic );
}
If ($ soft! = "None "){
Copy ($ soft, "channelsoft/$ soft_name ");
Unlink ($ soft );
}
$ Dbh = mysql_connect ('localhost', 'uesrname', 'passward ');
Mysql_select_db ('yourtable ');
$ Dat = date ("Y-m-d h: I: s ");
$ Query = "insert into news (title, kind, content, pic, timer, soft) values ('$ title',' $ kind', '$ content ', '$ picname', now (),' $ soft_name ')";
$ Res = mysql_query ($ query, $ dbh );

$ Err = mysql_error ();
If ($ err) {echo $ err; exit ();}
Echo"

";
Echo"Input successful

";
?>
*********************************
End of insert. php
*********************************

*********************************
News File: news. php
*********************************


Display type 1



$ Db = mysql_connect ("localhost", "username", "passward ");
Mysql_select_db ("yourtable", $ db );
$ Result = mysql_query ("select id, title from news where kind = 'Type 1' order by timer desc ");
For ($ a = 0; $ a <10; $)
{If (! ($ Ahrow = mysql_fetch_row ($ result) break;
$ Id = mysql_result ($ result, $ a, "id ");
$ Title = mysql_result ($ result, $ a, "title ");
Echo "". $ title ."
";
}
If (! Isset ($ id) $ id = mysql_result ($ result1, 0, "id ");
$ Result = mysql_query ("select * from news where id = $ id order by timer desc ");
$ Rows = mysql_fetch_row ($ result );
Echo"
";
Print $ rows [2];
Echo"
$ Rows [5] ";
If (strlen ($ rows [4])> 0) echo"

";
Echo str_replace ("\ r ","
", Str_replace (" "," ", $ rows [3]);
If (strlen ($ rows [6])> 0) echo"

> Click to download

";
?>


*********************************
End of news. php
*********************************


[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]

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.