html中倒序怎么打

html-css034

html中倒序怎么打,第1张

按id号从小到大排列

sql = "select * from tablename order by id asc"

按id号从大到小排列

sql = "select * from tablename order by id desc"

举例如下:

下面是一段正常的源码,它可以正常查询出倒序结果:

<!--#include file="conn.asp" -->

<head>

<title>回眸一笑</title>

<style><!--@import url(in/index.css)--></style>

<style><!--@import url(in/layer.css)body,td,th {

font-family: 宋体

color: #000

}

--></style>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312"></head>

<body text="#000000" >

<div id="newest">

<div id="ntitle" align="right">最新10篇帖子:</div>

<div id="space"></div>

<div id="nmarquee">

<table width="100%" height="12" border="0" cellpadding="0" cellspacing="0">

<tr>

<td id=demo1>

<table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">

<tr>

<%

Dim nSql

nSql="Select top 10 * From [Dv_Topic] Order By TopicID DESC"

Dim nRs

Set nRs=Server.CreateObject("ADODB.RecordSet")

nRs.Open nSql,Conn1,1,1

while not nRs.eof

%>

<td height="17"><table width="500"><tr><td width="492" height="10">

<a href='../../xiabbs/Dvbbs8.2.0_Ac/dispbbs.asp?TopicIDid=<%=nRs("TopicID")%>'>

<strong><font color="#333366"><%=left(nRs("PostUserName"),5)%></font></strong>

<font color="#FF3366">发贴于 </font>

<strong><font color="#333366"><%=left(nRs("DateAndTime"),12)%></font></strong>:<%=left(nRs("Title"),20)%>

</a></td></tr></table></td>

<%

nRs.movenext

wend

nRs.close:set nRs = nothing

%>

但是把它的链接更改,使它指向其它ID,但查询结果却顺序显示了。代码如下:

<!--#include file="conn.asp" -->

<head>

<title>回眸一笑</title>

<style><!--@import url(in/index.css)--></style>

<style><!--@import url(in/layer.css)body,td,th {

font-family: 宋体

color: #000

}

--></style>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312"></head>

<body text="#000000" >

<div id="newest">

<div id="ntitle" align="right">最新10篇帖子:</div>

<div id="space"></div>

<div id="nmarquee">

<table width="100%" height="12" border="0" cellpadding="0" cellspacing="0">

<tr>

<td id=demo1>

<table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">

<tr>

<%

Dim nSql

nSql="Select top 10 * From [Dv_Topic] Order By TopicID DESC"

nSql="Select top 10 * From [Dv_Topic] Order By boardid DESC"<!--这里添加了查询表,以为下面链接提供ID链接-->

Dim nRs

Set nRs=Server.CreateObject("ADODB.RecordSet")

nRs.Open nSql,Conn1,1,1

while not nRs.eof

%>

<td height="17"><table width="500"><tr><td width="492" height="10">

<!--下面的链接添加了boardid以便动态链接。-->

<a href='../../xiabbs/Dvbbs8.2.0_Ac/dispbbs.asp?boardid=<%=nRs("boardid")%>&id=<%=nRs("TopicID")%>'>

<strong><font color="#333366"><%=left(nRs("PostUserName"),5)%></font></strong>

<font color="#FF3366">发贴于 </font>

<strong><font color="#333366"><%=left(nRs("DateAndTime"),12)%></font></strong>:<%=left(nRs("Title"),20)%>

</a></td></tr></table></td>

<%

nRs.movenext

wend

nRs.close:set nRs = nothing

%>

分享

追问:

除了这个还有其他代码么?比如<ol>延伸的之类的

追答:

01.1 <!DOCTYPE html>

02.2 <html>

03.3 <head>

04.4 <meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

05.5 <title>ol元素的逆向排序</title>

06.6 </head>

07.7 <body>

08.8 <ol>

09.9 <li>item1: I'm a boy</li>

10.10 <li>item2: I'm a boy too</li>

11.11 <li>item3: Are you kidding me?</li>

12.12 </ol>

13.13 </body>

14.14 </html>

看到的效果就是:

到这里我们就发现一个神圣的有序列表产生了。

接下来就是介绍怎么实现元素ol的逆向排序显示了。实现的方法是很多的,在这里介绍三种方法,如果您有更好的方法,欢迎在下面的评论中提出。这里提到的三种方法分别使用HTML、CSS和JavaScript实现,样样都有,随你挑。

首先介绍一下HTML的实现方法,这个办法应该是最简单有效的,因为在HTML5中已经为这个标签添加了一个属性:reversed,方法也很简单,只需要在ol元素的起始标签中添加一个 reversed属性,就能非常容易实现元素ol的降序排序显示,我们来看一看效果:

view sourceprint?

1.1 <ol reversed>

2.2 <li>item1: I'm a boy</li>

3.3 <li>item2: I'm a boy too</li>

4.4 <li>item3: Are you kidding me?</li>

5.5 </ol>

在有序列表元素ol,添加属性reversed,下面进行验证:

1、起始代码

2、起始效果

3、设置代码

4、设置结果

内容是倒序没关系,可使用两次排序,即可解决。

在表格中A列前新插入1列,依次往下填写数字序号1,2,3...(可以使用向下填充)。

然后全选数据,点击“排序”,选择按A列排序(降序),然后删除A列,即可使你的顺序正常了。