如何在网页里按顺序显示数据库里所有的记录?

我要在网页里按顺序显示数据里的记录。我的记录都很长,所以要一条一条地显示。而且要它们不停地循环显示。用的语言是HTML,VBscript,ASP,数据库是Microsof... 我要在网页里按顺序显示数据里的记录。我的记录都很长,所以要一条一条地显示。而且要它们不停地循环显示。

用的语言是HTML,VBscript,ASP,数据库是Microsoft SQL Sever 2000.

谢谢电脑高手帮忙!

请写出完整代码吧。
展开
 我来答
百度网友00d80fc49
2006-10-13 · TA获得超过114个赞
知道小有建树答主
回答量:347
采纳率:0%
帮助的人:257万
展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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={sql server};server=你的服务器名称;UID=sa;PWD=sa;database=你的数据库名称"
conn.open connstr
%>
bai_du_spy
2006-10-13 · TA获得超过573个赞
知道答主
回答量:73
采纳率:0%
帮助的人:0
展开全部
用于网页中表格排序的js代码- -

<SCRIPT language=JavaScript>
var dom = (document.getElementsByTagName) ? true : false;
var ie5 = (document.getElementsByTagName && document.all) ? true : false;
var arrowUp, arrowDown;
if (ie5 || dom)
initSortTable();
function initSortTable() {
arrowUp = document.createElement("SPAN");
var tn = document.createTextNode("↓");
arrowUp.appendChild(tn);
arrowUp.className = "arrow";
arrowDown = document.createElement("SPAN");
var tn = document.createTextNode("↑");
arrowDown.appendChild(tn);
arrowDown.className = "arrow";
}

function sortTable(tableNode, nCol, bDesc, sType) {
var tBody = tableNode.tBodies[0];
var trs = tBody.rows;
var a = new Array();

for (var i=0; i<trs.length; i++) {
a[i] = trs[i];
}

a.sort(compareByColumn(nCol,bDesc,sType));

for (var i=0; i<a.length; i++) {
tBody.appendChild(a[i]);
}
}
function CaseInsensitiveString(s) {
return String(s).toUpperCase();
}
function parseDate(s) {
return Date.parse(s.replace(/\-/g, '/'));
}
function toNumber(s) {
return Number(s.replace(/[^0-9\.]/g, ""));
}
function compareByColumn(nCol, bDescending, sType) {
var c = nCol;
var d = bDescending;

var fTypeCast = String;

if (sType == "Number")
fTypeCast = Number;
else if (sType == "Date")
fTypeCast = parseDate;
else if (sType == "CaseInsensitiveString")
fTypeCast = CaseInsensitiveString;
return function (n1, n2) {
if (fTypeCast(getInnerText(n1.cells[c])) < fTypeCast(getInnerText(n2.cells[c])))
return d ? -1 : +1;
if (fTypeCast(getInnerText(n1.cells[c])) > fTypeCast(getInnerText(n2.cells[c])))
return d ? +1 : -1;
return 0;
};
}

function sortColumn(e) {
var tmp, el, tHeadParent;
if (ie5)
tmp = e.srcElement;
else if (dom)
tmp = e.target;
tHeadParent = getParent(tmp, "THEAD");
el = getParent(tmp, "TH");
if (tHeadParent == null)
return;

if (el != null) {
var p = el.parentNode;
var i;
if (el._descending) // catch the null
el._descending = false;
else
el._descending = true;

if (tHeadParent.arrow != null) {
if (tHeadParent.arrow.parentNode != el) {
tHeadParent.arrow.parentNode._descending = null;
}
tHeadParent.arrow.parentNode.removeChild(tHeadParent.arrow);
}
if (el._descending)
tHeadParent.arrow = arrowDown.cloneNode(true);
else
tHeadParent.arrow = arrowUp.cloneNode(true);
el.appendChild(tHeadParent.arrow);

// get the index of the td
for (i=0; i<p.cells.length; i++) {
if (p.cells[i] == el) break;
}
var table = getParent(el, "TABLE");
// can't fail

sortTable(table,i,el._descending, el.getAttribute("type"));
}
}

function getInnerText(el) {
if (ie5) return el.innerText; //Not needed but it is faster

var str = "";

for (var i=0; i<el.childNodes.length; i++) {
switch (el.childNodes.item(i).nodeType) {
case 1: //ELEMENT_NODE
str += getInnerText(el.childNodes.item(i));
break;
case 3: //TEXT_NODE
str += el.childNodes.item(i).nodeValue;
break;
}

}

return str;
}
function getParent(el, pTagName) {
if (el == null) return null;
else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
return el;
else
return getParent(el.parentNode, pTagName);
}

</SCRIPT>

<html>
<head>
<title>商品库存查询</title>
</head>
<body leftmargin="8" topmargin="8">
单击标题头的列就可以升降序
<table onclick="sortColumn(event)" width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#BBBBBB">
<THEAD>
<tr>
<th title="按商品名称排序" style="cursor:hand">商品名称</th>
<th title="按商品类别排序" style="cursor:hand">商品类别</th>
<th title="按规 格排序" style="cursor:hand">规格</th>
<th title="按单 位排序" style="cursor:hand">单位</th>
<th title="按单 价排序" style="cursor:hand" >单价(元)</th>
<th title="按库存数量排序" style="cursor:hand">库存数量</th>
</tr>
</THEAD>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#FFFFFF>
<td>妇科千金片</td>
<td>中成药</td>
<td>72s*150盒</td>
<td>盒</td>
<td>15</td>
<td>20</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#EEEEEE>
<td>复方地塞米松乳膏(皮炎平)</td>
<td>化学药制剂</td>
<td>10g*20支*40中包</td>
<td>支</td>
<td>12</td>
<td>36</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#FFFFFF>
<td>安神补脑液</td>
<td>中成药</td>
<td>10ml*10支*50盒</td>
<td>盒</td>
<td>11.5</td>
<td>86</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#EEEEEE>
<td>复方地巴唑氢氯噻嗪胶囊</td>
<td>化学药制剂</td>
<td>60s*200瓶</td>
<td>瓶</td>
<td>13.5</td>
<td>76</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#FFFFFF>
<td>枫蓼肠胃康片</td>
<td>中成药</td>
<td>0.24g*12s*2板*10盒*20中盒</td>
<td>盒</td>
<td>11.58</td>
<td>77</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#EEEEEE>
<td>乌鸡白凤丸(水蜜丸)</td>
<td>中成药</td>
<td>6g*10袋*40盒</td>
<td>盒</td>
<td>152.4</td>
<td>688</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#FFFFFF>
<td>复方利血平氨苯蝶啶片</td>
<td>化学药制剂</td>
<td>10s*300盒</td>
<td>盒</td>
<td>15.4</td>
<td>255</td>
</tr>
<tr onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#ACC7FF'" bgcolor=#EEEEEE>
<td>双料喉风散</td>
<td>中成药</td>
<td>1g*6瓶*60盒</td>
<td>盒</td>
<td>18.6</td>
<td>100</td>
</tr>
</table>
</body>
</html>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友9dd5ebf66d5
2006-10-13 · TA获得超过4654个赞
知道大有可为答主
回答量:3723
采纳率:0%
帮助的人:0
展开全部
按顺序显示出数据库里面的记录 ...?

SELECT * FROM tablenmae ORDER BY id ...

然后一条一条显示就好了 ...?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
yinlixing
2006-10-13 · 超过32用户采纳过TA的回答
知道答主
回答量:131
采纳率:0%
帮助的人:0
展开全部
你需要加分页效果 ,要不你的网页就是垃圾了.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2006-10-13
展开全部
已经通过消息发给你了~~你接收一下~
这里发不下!!!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(3)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式