News classification input and display system

Source: Internet
Author: User
Tags date character set strlen
The system can enter the title, content, pictures, related software, display will be based on whether there are pictures and related software to determine whether to show the content, open the page is displayed is the latest article, click on the table of contents will show before the article.
Set up the Channelimages and Channelsoft directories and set the permissions to 777.
*********************************
News table Structure
*********************************
# Host:localhost Database:yourdb
# --------------------------------------------------------

#
# Table structure for table ' yourtable '
#

CREATE TABLE News (
ID int (one) DEFAULT ' 0 ' not NULL auto_increment,
Kind varchar (16),
Title varchar (60),
Content text,
Pic varchar (30),
Timer datetime DEFAULT ' 0000-00-00 00:00:00 ' not NULL,
Soft varchar (30),
PRIMARY KEY (ID),
KEY Timer (timer)
);

*********************************
News entry File: insert.htm
*********************************
<title> News Entry </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" >
<form name= "Form1" enctype= "Multipart/form-data" action= "insert.php" method= "POST" >
<table width= "81%" border= "0" cellspacing= "2" cellpadding= "0" align= "center" >
<tr>
&LT;TD width= "11%" align= "right" bgcolor= "#CC0000" ><font color= "#FFFFFF" > title:</font></td>
&LT;TD bgcolor= "#E7E7E7" >
<input type= "text" name= "title" Size= ">"
</td>
</tr>
<tr>
&LT;TD align= "Right" bgcolor= "#CC0000" ><font color= "#FFFFFF" > Category:</font></td>
&LT;TD bgcolor= "#E7E7E7" >
<input type= "Radio" name= "Kind" value= "Type 1" >
Type 1
<input type= "Radio" name= "Kind" value= "Type 2" >
Type 2
<input type= "Radio" name= "Kind" value= "Type 3" >
Type 3
<input type= "Radio" name= "Kind" value= "type 4" >
Type 4</td>
</tr>
<tr>
&LT;TD width= "11%" align= "right" bgcolor= "#CC0000" ><font color= "#FFFFFF" > Content:</font></td>
&LT;TD bgcolor= "#E7E7E7" >
<textarea name= "Content" cols= "rows=" ></textarea>
</td>
</tr>
<tr>
&LT;TD width= "11%" align= "right" bgcolor= "#CC0000" ><font color= "#FFFFFF" > Pictures:</font></td>
&LT;TD bgcolor= "#E7E7E7" >
<input type= "file" name= "pic" size= ">"
</td>
</tr>
<tr>
&LT;TD width= "11%" align= "right" bgcolor= "#CC0000" ><font color= "#FFFFFF" > Software:</font></td>
&LT;TD bgcolor= "#E7E7E7" >
<input type= "file" name= "soft" size= ">"
</td>
</tr>
<tr>
&LT;TD width= "11%" align= "right" bgcolor= "#CC0000" > </td>
&LT;TD bgcolor= "#E7E7E7" >
<div align= "center" >
<input type= "Submit" name= "Submission" value= "submitted" >
</div>
</td>
</tr>
</table>
</form>
</body>
*********************************
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 "<p></p><p align=center>";
echo "<body>?>
*********************************
End of insert.php
*********************************

*********************************
News Display file: news.php
*********************************
<title> Display Type 1</title>
<meta http-equiv= "directory Type" content= "text/html; Character Set =gb2312 ">
<body bgcolor= "#FFFFFF" >
?
$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; $a + +)
{if (!) ( $ahrow =mysql_fetch_row ($result))) break;
$id =mysql_result ($result, $a, "id");
$title =mysql_result ($result, $a, "title");
echo "<a href=news.php?id=". $id. " > ". $title." </a><br> ";
}
if (!isset ($id)) $id =mysql_result ($result 1,0, "id");
$result =mysql_query ("SELECT * from news where id= $id ORDER by timer DESC");
$rows =mysql_fetch_row ($result);
echo "<br><center><font color=ff0000>";
Print $rows [2];
echo "</font><br> $rows [5]</center>";
if (strlen ($rows [4]) >0) echo "<p>Echo str_replace ("R", "<br>", Str_replace ("", "", $rows [3]));
if (strlen ($rows [6]) >0) echo "</p><p align=right><a href=channelsoft/$rows [6]>>> Click Download < /a></p> ";
?>
</body>
*********************************
End of news.php
*********************************



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.