Php连接数据库获取新闻列表的代码
最好添加注释,最好用到for循环和数组的知识,能不把整个网页代码给我看看最好了,是那种初学看得懂的用来教学的代码,新手谢了...
最好添加注释,最好用到for循环和数组的知识,能不把整个网页代码给我看看最好了,是那种初学看得懂的用来教学的代码,新手谢了
展开
2个回答
2013-11-21
展开全部
<?php
$conn = mysql_connect ( "localhost", "root", "" );
mysql_select_db ( "bookdb" );
mysql_query ( "set names gbk" );
$sql = "select * from book;";
$rs = mysql_query ( $sql );
?>
<html>
<style type="text/css">
* {
font-family: "宋体";
fony-size: 12px
}
;
.tbhead {
background-color: #698CC3;
border: 1px solid #FFFFFF;
color: #FFFFFF;
font-weight: 800;
}
;
.tbleft {
border: 1px dashed #698CC3;
background-color: #EFEFEF;
}
;
.tbright {
background-color: #FFFFFF;
border: 1px dashed #698CC3;
}
;
</style>
<body bgcolor="#9ac5b5">
<h1 align="center">所有书籍信息</h1>
<table style="border: 1px dashed #698CC3; width: 100%; line-height: 200%;"
cellpadding="0px" cellspacing="0px">
<tr>
<td align="right" colspan="7" class="tbhead"><a href="add.php">添加书籍</a></td>
</tr>
<tr>
<th class="tbleft">编号</th>
<th class="tbleft">书名</th>
<th class="tbleft">出版社</th>
<th class="tbleft">出版时间</th>
<th class="tbleft">操作</th>
</tr>
<?php
while ( $arr = mysql_fetch_array ( $rs ) ) {
echo "<tr align='center'>";
echo "<td class='tbright'>" . $arr ["bid"] . "</td>";
echo "<td class='tbright'>" . $arr ["bname"] . "</td>";
echo "<td class='tbright'>" . $arr ["bcbs"] . "</td>";
echo "<td class='tbright'>" . $arr ["btime"] . "</td>";
echo "<td class='tbright'><a href='del.php?bid=" . $arr ["bid"] . "'>删除</a> <a href='update.php?bid=" . $arr ["bid"] . "'>修改</a></td>";
echo "</tr>";
}
mysql_free_result ( $rs );
mysql_close ( $conn );
?>
</table>
</body>
</html>
$conn = mysql_connect ( "localhost", "root", "" );
mysql_select_db ( "bookdb" );
mysql_query ( "set names gbk" );
$sql = "select * from book;";
$rs = mysql_query ( $sql );
?>
<html>
<style type="text/css">
* {
font-family: "宋体";
fony-size: 12px
}
;
.tbhead {
background-color: #698CC3;
border: 1px solid #FFFFFF;
color: #FFFFFF;
font-weight: 800;
}
;
.tbleft {
border: 1px dashed #698CC3;
background-color: #EFEFEF;
}
;
.tbright {
background-color: #FFFFFF;
border: 1px dashed #698CC3;
}
;
</style>
<body bgcolor="#9ac5b5">
<h1 align="center">所有书籍信息</h1>
<table style="border: 1px dashed #698CC3; width: 100%; line-height: 200%;"
cellpadding="0px" cellspacing="0px">
<tr>
<td align="right" colspan="7" class="tbhead"><a href="add.php">添加书籍</a></td>
</tr>
<tr>
<th class="tbleft">编号</th>
<th class="tbleft">书名</th>
<th class="tbleft">出版社</th>
<th class="tbleft">出版时间</th>
<th class="tbleft">操作</th>
</tr>
<?php
while ( $arr = mysql_fetch_array ( $rs ) ) {
echo "<tr align='center'>";
echo "<td class='tbright'>" . $arr ["bid"] . "</td>";
echo "<td class='tbright'>" . $arr ["bname"] . "</td>";
echo "<td class='tbright'>" . $arr ["bcbs"] . "</td>";
echo "<td class='tbright'>" . $arr ["btime"] . "</td>";
echo "<td class='tbright'><a href='del.php?bid=" . $arr ["bid"] . "'>删除</a> <a href='update.php?bid=" . $arr ["bid"] . "'>修改</a></td>";
echo "</tr>";
}
mysql_free_result ( $rs );
mysql_close ( $conn );
?>
</table>
</body>
</html>
2013-11-21
展开全部
……这种很简单的东西都要问,就算我发出来,你也会问地更多,还是算了……
自己去看phpcms2008 , dedecms 学习吧。
自己去看phpcms2008 , dedecms 学习吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询