一 数据库脚本
CREATE TABLE `tb_person` (
`id` int(4) NOT NULL,
`p_title` varchar(50) NOT NULL,
`p_content` mediumtext NOT NULL,
`p_time` date NOT NULL,
`u_id` int(4) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
--
-- 转存表中的数据 `tb_person`
--
INSERT INTO `tb_person` (`id`, `p_title`, `p_content`, `p_time`, `u_id`) VALUES
(11, '乒乓球单打决赛', '今天下午4点,在体育馆举行本次乒乓球球单打决赛。\r\n参赛人员:全体员工\r\n 2016年12月4日', '2016-12-04', 10),
(12, '换休', '由于公司这周日停电,所以将周一与周日换休,周日正常上班,周一休息,请注意上班时间', '2016-12-04', 9);
二 PHP脚本
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>企业公告信息展示</title>
<link rel="stylesheet" type="text/css" href="css/font.css">
<style type="text/css">
<!--
.STYLE1 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="703" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#669933" ><table width="703" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td height="25" colspan="5" align="center" bgcolor="#FFFFFF"><span class="STYLE1">企业公告信息展示</span></td>
</tr>
<tr>
<td width="187" height="25" align="center" bgcolor="#CCFF66">标题</td>
<td width="173" align="center" bgcolor="#CCFF66">内容</td>
<td width="101" align="center" bgcolor="#CCFF66">发布时间</td>
</tr>
<?php
$conn=mysql_connect("localhost","root","root");
mysql_select_db("db_database04",$conn);
mysql_query("set names gb2312");
$sql=mysql_query("select * from tb_person order by u_id desc",$conn);
$info=mysql_fetch_array($sql);
if($info==false){
echo "暂无公告信息!";
}
else{
do{
?>
<tr>
<td height="25" align="center" bgcolor="#FFFFFF"><?php echo $info[p_title];?></td>
<td height="25" align="center" bgcolor="#FFFFFF"><?php echo $info[p_content];?></td>
<td height="25" align="center" bgcolor="#FFFFFF"><?php echo $info[p_time];?></td>
</tr>
<?php
}while($info=mysql_fetch_array($sql));
}
?>
</table></td>
</tr>
</table>
</body>
</html>
三 运行效果

本文介绍了一个简单的公告展示系统实现过程,包括数据库表结构定义及PHP页面展示代码。该系统能够从数据库中读取公告信息,并在网页上进行展示。
2737

被折叠的 条评论
为什么被折叠?



