打印本页〗〖打印选项
关于控制显示数据库记录的代码
ADMIN:
    您好!前几天在贵网提问的同时上传OLE、文本的问题已经得到解决,现在在调用数据库记录显示的时候碰到了新问题!请求贵网能够帮助解决!
    在此将代码提供如下,要求显示的结果是5行3列,多余的记录进行翻页。
    <%     
dim filename,postion
filename=request.servervariables("script_name")
postion=instrrev(filename,"/")+1
filename=mid(filename,postion)
  set rs=Server.CreateObject("adodb.recordset")     
  sql="SELECT * FROM chanpin ORDER BY id DESC"     
  rs.Open sql,conn,1,1  
  %>
<%
if not(rs.bof and rs.eof)then
pages=6 '控制每页显示的条目数
rs.pagesize=pages
if not isempty(request.querystring("page"))then
thispage=clng(request.querystring("page"))
else
thispage=1
end if
rscount=rs.recordcount
if thispage="" then thispage=1
if thispage<1 then thispage=1
if(thispage-1)*pages>rscount then
if(rscount mod pages)=0 then
thispage=rscount\pages
else
thispage=rscount\pages+1
end if
end if
if(rscount mod pages)=0 then
allpages=rscount\pages
else
allpages=rscount\pages+1
end if
rs.absolutepage=thispage
i=1
%>
        <tr><%do while not rs.eof and pages>0%><td width="200"><p>
          </p>
          </td>
          <td width="200"><p>名称:<%=rs("mingcheng")%> </p>
            <p>规格:<%=rs("guige")%> </p>
            <p>价格:<%=rs("jiage")%> </p>
            <p>详细信息:<%=rs("xiangxi")%> </p>
          <p>图像: <img src=showing.asp?id=<%=rs("id")%> width="100" height="100"></p></td>
<%
if(i mod 1)=0 then
%> 
</tr>
<%end if%>
          <%
    pages=pages-1
rs.movenext
i=i+1
loop
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
    </table>
<table width="61%" border="0" align='center'>
<tr>
<td><center>
共<%=allpages%>页 当前第<%=thispage%>页 
<% if thispage<>1 then %>
<a href="<%=filename&"?page=1"%>">首页</a>
<a href="<%=filename&"?page="&(thispage-1)%>">上页</a>
<% end if %>
<% if thispage<>allpages then %>
<a href="<%=filename&"?page="&(thispage+1)%>">下页</a>
<a href="<%=filename&"?page="&allpages&""%>">末页</a>
<%end if%>
</center></td>
</tr>
</table>



文章作者:未知