新闻分类录入、显示系统

本系统可以录入标题、内容、图片、相关软件,显示时会根据是否有有图片和相关软件来判断是否显示该项内容,打开页面显示的是最新的一片文章,点击目录会显示之前的文章。
建立channelimages和channelsoft目录,并把权限设为777。
*********************************
news表结构
********************************* #
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 ‘0000-00-00
00:00:00’ NOT NULL, soft varchar(30), PRIMARY KEY (id), KEY timer
(timer) );
*********************************
新闻录入文件:insert.htm
********************************* html
head title新闻录入/title meta content=text/html; charset=gb2312 /head
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 trtd width=11% align=right
bgcolor=#CC0000font color=#FFFFFF标题:/font/td td
bgcolor=#E7E7E7input type=text name=title size=60 /td /tr trtd
align=right bgcolor=#CC0000font color=#FFFFFF类别:/font/td td
bgcolor=#E7E7E7input type=radio name=kind value=类型1 类型1input
type=radio name=kind value=类型2 类型2 input type=radio name=kind
value=类型3 类型3 input type=radio name=kind value=类型4 类型4/td /tr
trtd width=11% align=right bgcolor=#CC0000font
color=#FFFFFF内容:/font/td td bgcolor=#E7E7E7textarea name=content
cols=60 rows=10/textarea /td /tr trtd width=11% align=right
bgcolor=#CC0000font color=#FFFFFF图片:/font/td td
bgcolor=#E7E7E7input type=file name=pic size=60 /td /tr trtd width=11%
align=right bgcolor=#CC0000font color=#FFFFFF软件:/font/td td
bgcolor=#E7E7E7input type=file name=soft size=60 /td /tr trtd width=11%
align=right bgcolor=#CC0000/td td bgcolor=#E7E7E7div align=centerinput
type=submit name=Submit value=提 交 /div /td /tr /table /form
/body/html*********************************
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/pp ; echo bodyh2录入成功/h2/body/p; ?
********************************* end
of insert.php
*********************************
*********************************
新闻显示文件:news.php
********************************* html
head title显示类型1/title meta 目录类型 content=文本/html; 字符集=gb2312
/head body bgcolor=#FFFFFF ?
$db=mysql_connect(localhost,username,passward);
mysql_select_db(yourtable,$db); $result=mysql_query(select id,title
from news where kind=’类型1′ order by timer desc); for($a=0;$a10;$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./abr; } 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 brcenterfont color=ff0000; print
$rows[2]; echo /fontbr$rows[5]/center; if (strlen($rows[4])0) echo
pimg src=channelimages/$rows[4] align=right; echo
str_replace(/r,br,str_replace( ,,$rows[3])); if
(strlen($rows[6])0) echo /pp align=righta
href=channelsoft/$rows[6]点击下载/a/p; ? /body /html
********************************* end
of news.php
*********************************

//此页面为say.php ? include signup/mysql.inc; if($id1){ $sql=select *
from $table where id=’$id1′;//显示回复题目 $result=mysql_query($sql)or
die(mysql_error()); $row=mysql_fetch_array($result);
$title=RE:.$row[title]; } $ip=$REMOTE_ADDR; $sql=select * from
user_stus where ip=’$ip’;//查询当前用户名 $result=mysql_query($sql)or
die(mysql_error()); $row=mysql_fetch_array($result);
if(!$row)//判断用户是否登陆 { echo htmldiv id=Layer2 z-index:1BRBRBRBR;
echo div id=Layer3 z-index:2img src=pic/3.gif width=15 height=15/div;
echodiv ;echo pfont size=2 color=#FF33CC嘻嘻!! 请先登陆/font/p;
echopfont size=2 color=#FF33CCa
href=’.$PHP_SELF.?p=1&&table=$table’返回/a/font/p /div /html; exit(); }
else $userid=$row[userid]; if($ok) { if($title==||$content==) { echo
BR请您添完整后提交; } else{ $id=time();//提交文章 $date1=date(Y/m/d);
$title=htmlspecialchars($title); $content=htmlspecialchars($content);
$sql=select * from .$table; $result=mysql_query($sql)or
die(mysql_error()); $row1=mysql_num_rows($result); $row1++; if($id1){
$sql=insert into bbs_re
(id,userid,date1,title,content)values(‘$id’,’$userid’,’$date1′,’$title’,’$content’);
mysql_query($sql)or die(mysql_error()); $sql=select * from .$table.
where id=’$id1′; $result=mysql_query($sql)or die(mysql_error());
$lin=mysql_fetch_array($result); for($i=1;$i6;$i++) { $re=r.$i;
if(!$lin[$re]) break; } $sql=update .$table. set .$re.=’$id’ where
id=’$id1′; } else$sql=insert into .$table.
(id,userid,date1,title,content,row)values(‘$id’,’$userid’,’$date1′,’$title’,’$content’,’$row1′);
$result=mysql_query($sql)or die(mysql_error()); if($result) {
header(Location:php3.php?p=1&&table=$table); exit ; } } } ? html head
titlexiaoyang/title meta content=text/html; charset=gb2312 script
language=JavaScript1.2 src=js/menu_comment.js/script script
language=JavaScript1.2 src=js/fw_menu.js/script script
language=JavaScript !– function MM_reloadPage(init) {//reloads the
window if Nav4 resized if (init==true) with (navigator) {if
((appName==Netscape)&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW ||
innerHeight!=document.MM_pgH) location.reload(); }
MM_reloadPage(true); // — /script /head body bgcolor=#FFFFFF
text=#000000 div id=Layer1 style=position:absolute; left:31px; top:1px;
width:560px; height:46px; z-index:10 script
language=JavaScript1.2fwLoadMenus();/script/div div id=Layer6
style=position:absolute; left:409px; top:29px; width:118px; height:17px;
z-index:6/div div id=Layer5 style=position:absolute; left:86px;
top:63px; width:464px; height:303px; z-index:7form name=form1
method=post action=? echo $PHP_SELF ? table width=98% border=1
cellspacing=0 cellpadding=0 bordercolor=#FF99FF trtd width=26%
height=42div align=centerfont size=2 color=#FF33FF题目/font/div /td td
width=74% height=42input type=text name=title size=40 value=?echo $title
;? onMouseover=this.document.form1.title.focus();return true input
type=hidden name=table value=?echo $table ;? input type=hidden name=id1
value=? echo $id1 ;? br /td /tr trtd width=26% height=172div
align=centerfont size=2 color=#FF33FF内容/font/div /td td width=74%
height=172textarea name=content cols=40 rows=10 wrap=physical
value=?echo $content ;?
onMouseOver=this.document.form1.content.focus()/textarea /td /tr tr td
width=26% div align=center input type=reset name=Submit2 value=重写 /div
/td td width=74% div align=center input type=submit name=ok value=发表
/div /td /tr /table p/p /form /div div id=back style=position:absolute;
left:455px; top:30px; width:85px; height:3px; z-index:8hr color=#ff9999
noshade /div div id=goback style=position:absolute; left:461px;
top:23px; width:120px; height:16px; z-index:9div align=centera
href=php3.php?p=1&&table=?echo $table ;? target=_self
onMouseover=window.status=” ;return truefont size=2
color=#FF33FF返回/font/a/div /div p/p p/p /body /html

发表评论

电子邮件地址不会被公开。 必填项已用*标注