怎么样在网页上显示数据库里所有的记录啊?
发布网友
发布时间:2022-04-23 20:33
我来回答
共4个回答
热心网友
时间:2023-10-23 18:22
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<!--#include file="inc/css.css"-->
</head>
<!--#include file="inc/connection.asp"-->
<%
dim pgnum,pgsize,pgcount,i,m
pgnum=request("pgnum")
pgsize=request("pgsize")
if pgnum="" then
pgnum=1
else
pgnum=cint(pgnum)
end if
if pgsize="" then
pgsize=15
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from 管理员信息表 order by 管理员id desc"
rs.open sql,conn,1,1
if rs.eof or rs.bof then
msg="没有管理员信息!"
response.Write "<center><span class=""STYLE1"">" & msg & "</span></center>"
end if
if not rs.eof or not rs.bof then
rs.movefirst
rs.pagesize=pgsize
rs.absolutepage=pgnum
pgcount=rs.pagecount
pgcount=cint(pgcount)
if pgnum > pgcount then
pgnum=1
rs.absolutepage=pgnum
end if
%>
<body>
<form action="editmanage.asp" method="post" name="form1">
<table width="750" border="0" align="center" >
<tr>
<td width="80" height="17" align="left" valign="middle" class="STYLE5">管理员列表</td>
<td width="660" valign="middle">
<hr size="1" align="left" width="80%" color="#CCCCCC" /></td>
</tr>
<tr valign="top" align="center">
<td colspan="2" style="border:1px solid #CCCCCC" height="300" align="center" width="100%">
<table width="100%" border="0" align="center">
<tr>
<td width="100" height="20" align="center" valign="middle" class="STYLE5">管理员ID</td>
<td width="100" align="center" valign="middle" class="STYLE5">管理员名</td>
<td width="120" align="center" valign="middle" class="STYLE5">电子邮件</td>
<td width="80" align="center" valign="middle" class="STYLE5">管理员类别</td>
</tr>
<%
i=0
while not rs.eof and i < pgsize
%>
<tr align=center onmouseover="this.bgColor='#cccccc';" onmouseout="this.bgColor='';" style="border:1px solid #CCCCCC">
<td class="STYLE1"><input name="manage_id" type="radio" value="<%=rs("管理员id")%>"/><%=rs("管理员id")%></td>
<td class="STYLE1"><%=rs("管理员名")%></td>
<td class="STYLE1"><%=rs("管理员email")%></td>
<td class="STYLE1"><%=rs("管理员类别")%></td>
</tr>
<%
rs.movenext
i=i+1
wend
%>
</table>
</td>
</tr>
</table>
<%
end if
rs.close
set rs=nothing
%>
<table width="750" border="0" align="center" >
<tr>
<%if pgcount >0 then%>
<td width="15%" align="left"><span class="STYLE1">当前页<%=pgnum%>/<%=pgcount%></span></td>
<%else%>
<td width="15%" align="left" class="STYLE1">当前页0/0</td>
<%end if%>
<td width="70%" align="right"><a href="managetable.asp?pgnum=1" class="STYLE1">首页</a> <span class="STYLE1">|</span>
<%if pgnum > 1 then%>
<a href="managetable.asp?pgnum=<%=pgnum-1%>" class="STYLE1">上一页</a>
<%else%>
<font color="#CCCCCC" class="STYLE1">上一页</font>
<%end if%> <span class="STYLE1">|</span>
<%if pgnum < pgcount then%>
<a href="managetable.asp?pgnum=<%=pgnum+1%>" class="STYLE1">下一页</a>
<%else%>
<font color="#CCCCCC" class="STYLE1">下一页</font>
<%end if%> <span class="STYLE1">|</span> <a href="managetable.asp?pgnum=<%=pgcount%>" class="STYLE1">尾页</a> <span class="STYLE1">|</span> <span class="STYLE1">转到第</span>
<select name="sel_pg" onchange="javascript:location=this.options[this.selectedIndex].value;" class="STYLE1">
<%for m=1 to pgcount
if m=pgnum then%>
<option value="managetable.asp?pgnum=<%=m%>" selected="selected"><%=m%></option>
<%else%>
<option value="managetable.asp?pgnum=<%=m%>"><%=m%></option>
<%end if
next%>
</select>
<span class="STYLE1">页</span> </td>
</tr>
</table>
<table width="750" border="0" align="center">
<tr>
<td height="22" width="469"></td>
<td width="89" align="center" valign="middle"><input name="button1" type="button" id="button1" value=" 添加 ">
<script language="vbscript" for=button1 event=onclick>
window.location.href="addmanage.asp"
</script> </td>
<td width="88" align="center" valign="middle"><input name="submit1" type="submit" id="button2" value=" 修改 "></td>
<td width="86" align="center" valign="middle"><input name="submit2" type="submit" id="button3" value=" 删除 "></td>
</tr>
</table>
</form>
</body>
</html>
带分页~~你把数据库的名字改了~~
connection.asp文件是
<%
set conn=server.CreateObject("adodb.connection")
connstr="driver=;server=你的服务器名称;UID=sa;PWD=sa;database=你的数据库名称"
conn.open connstr
%>
热心网友
时间:2023-10-23 18:22
<%
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from dingdang SC"
rs.open sql,conn,1,3
%>
热心网友
时间:2023-10-23 18:23
select * from dingdang
热心网友
时间:2023-10-23 18:23
sql="select * from dingdang order by 'id' DESC";