PHP中的循环语句输出企业公告信息
2017-04-12 10:24
162 查看
一 数据库脚本
二 PHP脚本
三 运行效果
大小: 39.6 KB
查看图片附件
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>
三 运行效果
大小: 39.6 KB
查看图片附件
相关文章推荐
- PHP字符串拼接语句顺序,导致输出不正常
- PHP集成华为企业信息机
- PHP中for循环语句的几种变型
- PHP循环输出变量
- 将行信息带入后台或者其他页面,如何迭代循环输出form中指定list中的对象
- PHP中for循环语句的几种变型
- 控制PHP的错误输出方式:直接输出至荧幕或将错误信息记录到错误日志文件内
- PHP基本语法(五)—— 循环语句
- PHP循环语句
- ubuntu+apache2+php禁止输出notice信息
- PHP集成华为企业信息机
- 关于PHP中for循环语句的几种变型
- php循环输出数据库内容的代码
- PHP提取数据库内容中的图片地址并循环输出
- php循环控制语句
- PHP中for循环语句的几种“变态”用法
- php循环输出数据库内容的代码
- php在eclipse的控制台console输出调试信息功能实现
- php for 循环语句使用方法详细说明
- [转]输出从1到1000的数,不能使用循环和条件语句