Cómo hacer que las páginas web se muestren en orden inverso después de leer la base de datos
sql = "select * from tablename order by id asc"
Ordenar por número de identificación de mayor a menor
sql = "select * from tablename order by id desc"
El ejemplo es el siguiente:
El siguiente es el código fuente de los resultados de una consulta normal en orden inverso:
lt;! --#include file="conn.asp" --gt;
lt;headgt;
lt;titlegt; Mirando hacia atrás en el pasadolt;/titlegt;
lt;estilogt;lt;! --@importar url(en/index.css);--gt;lt;/stylegt;
lt;stylegt;lt;!--@importar url(en/layer.css);body , td, th {
familia de fuentes: Dinastía Song
color: #000
}
--gt; lt ;/stylegt;
lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"gt;lt;/headgt;
lt ; texto del cuerpo="#000000" gt;
lt; div id="más nuevo"gt; div id="ntitle" align="right"gt; 10 Artículos:lt;/divgt;
lt;div id="space"gt;lt;/divgt;
lt;div id="nmarquee"gt;
lt; ancho de tabla="100" altura="12" border="0" cellpadding="0" cellpacing="0"gt;
lt;trgt;
lt;td id= demo1gt;
lt;table width="100" height="35" border="0" cellpadding="0" cellpacing="0"gt;
lt;trgt;
lt;
Dim nSql
nSql="Seleccione los 10 mejores * de [Dv_Topic] Ordenar por TopicID DESC" p>
Dim nRs
Establecer nRs=Server.CreateObject("Dv_Topic" Ordenar por TopicID DESC).
CreateObject("ADODB.RecordSet")
nRs.Open nSql, Conn1, 1, 1
mientras no nRs.eof
gt;
lt;td height="17"gt;lt;table width="500"gt;lt;trgt;lt; td width="492" height="10"gt;
lt ;a href='.../.../xiabbs/Dvbbs8.2.0_Ac/dispbbs.asp?TopicIDid=lt;=nRs("TopicID")gt;'gt;
lt;stronggt ;lt;font color="#333366"gt;lt;= left(nRs("PostUserName"),5)gt;lt;/fontgt;lt;/stronggt;
lt;font color= "#FF3366"gt; Publicado inlt;/fontgt;
lt;stronggt;lt;font color="#333366"gt;lt;=left(nRs("DateAndTime"), 12)gt ; lt;/fontgt;lt;/stronggt;:lt;=left(nRs("Título"),20)gt;
lt;/agt;lt;/tdgt;lt;/trgt; ;/tablegt;lt;/tdgt;
lt;
nRs.movvenext
wend
nRs.close:set nRs = nada
gt;
Pero cambie su enlace para que apunte a una ID diferente, pero los resultados de la consulta se mostrarán en orden.
El código es el siguiente:
lt; --#include file="conn.asp" --gt;
lt;headgt;
lt;titlegt;Mirando hacia atráslt;/titlegt;
lt;estilogt;lt;! --@importar url(en/index.css);--gt;lt;/stylegt;
lt;stylegt;lt;!--@importar url(en/layer.css);body , td, th {
familia de fuentes: Dinastía Song
color: #000
}
--gt; lt ;/stylegt;
lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"gt;lt;/headgt;
lt ; texto del cuerpo="#000000" gt;
lt; div id="más nuevo"gt; div id="ntitle" align="right"gt; 10 Artículos:lt;/divgt;
lt;div id="space"gt;lt;/divgt;
lt;div id="nmarquee"gt;
lt; ancho de tabla="100" altura="12" border="0" cellpadding="0" cellpacing="0"gt;
lt;trgt;
lt;td id= demo1gt;
lt;table width="100" height="35" border="0" cellpadding="0" cellpacing="0"gt;
lt;trgt;
lt;
Dim nSql
nSql="Seleccione los 10 mejores * de [Dv_Topic] Ordenar por TopicID DESC" p>
nSql="Seleccione los 10 mejores * De [Dv_Topic] Ordene por boardid DESC"lt;! --Aquí se ha agregado una tabla de búsqueda para proporcionar enlaces de ID para los siguientes enlaces--gt;
Dim nRs
Set nRs=Server.CreateObject("ADODB.RecordSet")
p>nRs.Open nSql, Conn1, 1, 1
mientras no nRs.eof
gt;
lt;td height="17 "gt;lt;table width="500"gt;lt;trgt;lt;td width="492" height="10"gt;
lt;! --El siguiente enlace agrega el boardid al enlace dinámico.
--gt;
lt;a href='./.../xiabbs/Dvbbs8.2.0_Ac/dispbbs.asp?boardid=lt;=nRs("boardid")gt;amp;id =lt;=nRs("TopicID")gt;'gt;
lt;stronggt;lt; color de fuente="#333366"gt;lt;=left(nRs("PostUserName"), 5 )gt;lt;/fontgt;lt;
lt;font color="#FF3366"gt;Publicado inlt; /fontgt;
lt;stronggt;lt;font color = "#333366"gt;lt;=left(nRs("DateAndTime"),12)gt;lt;/fontgt;lt;/stronggt;:lt;= left(nRs("Título"),20)gt; /p>
lt;/agt;lt;/tdgt;lt;/trgt;lt;/tablegt;lt;/tdgt;
lt;
nRs.
wend
nRs.close: establecer nRs = nada
gt;