网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > PHP实例
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.一个简单的PHP入门源程序.
.我的论坛源代码(三).
.用PHP编程语言开发动态WAP页面.
.如何开发一个虚拟域名系统.
.改进的IP计数器.
.PHP下MAIL的另一解决方案.
.一个从别的网站抓取信息的例子(域.
.在PHP3中实现SESSION的功能(三).
.人大复印资料处理程序_补充篇.
.php的计数器程序.
.用PHP和ACCESS写聊天室.
.用PHP发送MIME邮件(一).
.怎样用PHP来给网页做导航栏.
.模仿OSO的论坛(四).
.支持oicq头像的留言簿(二).
.基于mysql的bbs设计(二).
.一个简洁的多级别论坛.
.我用php+mysql写的留言本.
.NO3第三帝国留言簿制作过程.
.BBS(php & mysql)完整版(三).

新闻分类录入、显示系统

发表日期:2001-1-19


本系统可以录入标题、内容、图片、相关软件,显示时会根据是否有有图片和相关软件来判断是否显示该项内容,打开页面显示的是最新的一片文章,点击目录会显示之前的文章。
    建立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 http-equiv="Content-Type" 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">
    <tr>  
      <td width="11%" align="right" bgcolor="#CC0000"><font color="#FFFFFF">标题:</font></td>
      <td bgcolor="#E7E7E7">  
        <input type="text" name="title" size="60">
      </td>
    </tr>
    <tr>  
      <td align="right" bgcolor="#CC0000"><font color="#FFFFFF">类别:</font></td>
      <td bgcolor="#E7E7E7">  
        <input type="radio" name="kind" value="类型1">
        类型1  
        <input 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>
    <tr>  
      <td width="11%" align="right" bgcolor="#CC0000"><font color="#FFFFFF">内容:</font></td>
      <td bgcolor="#E7E7E7">  
        <textarea name="content" cols="60" rows="10"></textarea>
      </td>
    </tr>
    <tr>  
      <td width="11%" align="right" bgcolor="#CC0000"><font color="#FFFFFF">图片:</font></td>
      <td bgcolor="#E7E7E7">  
        <input type="file" name="pic" size="60">
      </td>
    </tr>
    <tr>  
      <td width="11%" align="right" bgcolor="#CC0000"><font color="#FFFFFF">软件:</font></td>
      <td bgcolor="#E7E7E7">  
        <input type="file" name="soft" size="60">
      </td>
    </tr>
    <tr>  
      <td width="11%" align="right" bgcolor="#CC0000">&nbsp;</td>
      <td bgcolor="#E7E7E7">  
        <div align="center">  
          <input 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></p><p align=center>";
echo "<body><h2>录入成功</h2></body></p>";
?>
*********************************
end of insert.php
*********************************

*********************************
新闻显示文件:news.php
*********************************
<html>
<head>
<title>显示类型1</title>
<meta http-equiv="目录类型" 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;$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($result1,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><img src=channelimages/$rows[4] align=right>";
echo str_replace("\r","<br>",str_replace(" ","&nbsp;",$rows[3]));
if (strlen($rows[6])>0) echo "</p><p align=right><a href=channelsoft/$rows[6]>>>点击下载</a></p>";
?>
</body>
</html>
*********************************
end of news.php
*********************************


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


上一篇:计算2000年01月01日起到指定日的天数 人气:9665
下一篇:PHP4实际应用经验篇(1) 人气:10373
浏览全部的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐