PHP实例之新闻发布
系统 CreateTABLE`news`(
`id`INTNOTNULLAUTO_INCREMENTPRIMARYKEY,
`p_time`DATETIMENOTNULL,
`title`VARCHAR(80)NOTNULL,
`detail`TEXTNOTNULL
)TYPE=innodb;
createtablenews(idintnotnullauto_incrementprimarykey,
p_timedatetimenotnull,
titlevarchar(80)notnull,
detailtextnotnull
)type=innodb;
数据库连接:conn.php
〈?
$conn=@
mysql_connect('localhost','root','')ordie(mysql_error()."不能连接到数据库!");//连接数据库;
$db=mysql_select_db('news',$conn);
$page_size=8;//每页最多显示新闻条数;
?〉
添加新闻页面:new.php
〈?
$title="新闻发布系统";
include("inc/header.inc");//头文件
?〉
〈styletype="text/css"〉
〈!--
.STYLE1{font-size:12px}
.title{
font-size:12px;
border-top-style:none;
border-right-style:none;
border-bottom-style:none;
border-left-style:none;
font-family:"宋体";
color:#993300;
line-height:normal;
height:16px;
}
.field{
font-family:"宋体";
font-size:12px;
color:#993333;
}
.STYLE2{
font-size:16px;
font-weight:bold;
}
--〉
〈/style〉
〈palign="center"class="STYLE2"〉PHP+Mysql新闻发布〈/p〉
〈formaction="post.php"method="post"name="frm"id="frm"〉
〈tablewidth="500"border="0"align="center"cellpadding="3"cellspacing="1"bgcolor="#0066FF"〉
〈tr〉
〈tdheight="1"bgcolor="#FFFFFF"〉〈spanclass="STYLE1"〉标题:〈/span〉〈/td〉