Php连接数据库获取新闻列表的代码

Php连接数据库获取新闻列表的代码,第1张

<?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 #698CC3width: 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>

<%

sql="select top 10 * from 表 order by 时间字段 DESC"

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,1,1

Do While Not rs.EOF %>

内容显示

<%

rs.movenext

loop

rs.close

set rs=nothing

%>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6698565.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存