答案:我见到有的网站好像可以把数据库的记录读到表格里去,是这样的吗?如何做到的?
可能是这样的,因为我们确实能把数据库里的记录用表格来储存,看看下面的办法:
<html>
<head>
<TITLE>用表格储存数据</TITLE>
</head>
<body>
<%
myDSN="DSN=Student;uid=student;pwd=magic"
mySQL="select * from publishers where state='NY'"
showblank=" "
shownull="-null-"set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
If rstemp.eof then
response.write "对不起,暂无匹配记录,请再检查一遍<br>"
response.write mySQL & "<br>对不起,无法创建表格……"
conntemp.close
set conntemp=nothing
response.end
end if
%>
<table border=1><tr><%
for each whatever in rstemp.fields%>
<td><b><%=whatever.name%></B></TD>
<% next %>
' 把标题写到表格名称栏
</tr><%
DO UNTIL rstemp.eof %>
<tr>
<% for each whatever in rstemp.fields
thisfield=whatever.value
if isnull(thisfield) then
thisfield=shownull
' 读取全部记录
end if
if trim(thisfield)="" then
thisfield=showblank
end if%>
<td valign=top><%=thisfield%></td>
<% next %>
</tr>
<%rstemp.movenext
LOOP%>
</table><%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
</body>
</html>
上一个:如何往数据库传递日期数据?
下一个:如何随机显示网站链接?