日期:2014-05-16 浏览次数:20591 次
<div style="float: left;height: 2%;padding-top: 1%;padding-left: 232px;padding-bottom: 4%;"><h1>文章作者——————————————文章标题—————————————文章时间</h1><hr></div>
<table class="article">
<div>
<tr>
<th width="100"><a style="font-size:18px;text-decoration:none;" href="www.baidu.com">Black-Hole</a></th>
<td>
<a style="padding-left: 273px;" href="http://www.baidu.com">PHP代码</a>
</td>
<td>
<a style="padding-left:25%;" href="http://www.baidu.com">2014年2月28号</a>
</td>
</tr>
</div>
CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL,
`age` tinyint(4) unsigned NOT NULL,
`addtime` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
<?php
//打开数据库
function opendb(){
$conn=@mysql_connect("localhost","root","") or die(mysql_error());
@mysql_select_db('demo',$conn) or die(mysql_error());
}
//关闭数据库
function closedb(){
@mysql_close() or die("關閉數據庫出錯!");
}
opendb();
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
$sqlstr = "select * from test order by addtime desc";
$query = mysql_query($sqlstr) or die(mysql_error());
while($thread=mysql_fetch_assoc($query)){
$result[] = $thread;
}
if($result){
foreach($result as $val){
echo $val['id'].' '.$val['name'].' '.$val['age'].' '.$val['addtime'].'<br>';
}
}
?>
<?php
//打开数据库
function opendb(){
$conn=@mysql_connect("localhost","root","") or die(mysql_error());
@