• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

新闻分类录入、显示系统_php基础

php 搞代码 4年前 (2022-01-26) 18次浏览 已收录 0个评论
文章目录[隐藏]

本系统可以录入标题、内容、图片、相关软件,显示时会根据是否有有图片和相关软件来判断是否显示该项内容,打开页面显示的是最新的一片文章,点击目录会显示之前的文章。
建立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
*********************************

新闻录入
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>

<body bgcolor=”#FFFFFF”>

标题:
类别:

类型1

类型2

类型3

类型4

内容:
图片:
软件:

*********************************
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 new(、本文来源gao@!dai!ma.com搞$$代^@码网*搞gaodaima代码s(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 “<body>

录入成功

“;
?>
*********************************
end of insert.php
*********************************

*********************************
新闻显示文件:news.php
*********************************

显示类型1
<meta http-equiv=”目录类型” content=”文本/html; 字符集=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=’类型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 “”.$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 “

>>点击下载

“;
?>

*********************************
end of news.php
*********************************

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:新闻分类录入、显示系统_php基础

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址