| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 470 人关注过本帖
标题:如何同时读取本ID和下一个ID内容
取消只看楼主 加入收藏
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
结帖率:79.07%
收藏
已结贴  问题点数:20 回复次数:3 
如何同时读取本ID和下一个ID内容
“陈”和“李”分别在字段1和字段2,在同一个ID下可以用如下方法:
select * from [users] where 字段1='陈' and 字段2='李'order by id asc"
但想在读取字段(陈)的同时又讯\读取相应的一下ID字段2(李),请教如何表达?
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: where 
2010-12-02 06:32
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
回复 2楼 hams
可否把代码简略写一下呢。谢谢。
2010-12-02 15:29
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
回复 2楼 hams
正想获得该记录的ID,然后读取该ID的下一条记录。 请简略写出代码。谢谢。
2010-12-04 04:44
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
如何同时读取本ID内容同时又读取相应的下一个ID的内容。请高手修改一下以下代码。谢谢!

文件1:Teacher.asp

<form method="POST" action="Teachers.asp" align=" center">
<p align="center"><strong><font color="#FF0000">输入</font>
<input type="text" name="userid123" <insize="20">
<input type="submit" value="提交"></TD>
</form>

文件2:Teachers.asp

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

<%
   MaxPerPage=50
   dim totalPut
   dim CurrentPage
   dim TotalPages
   dim i,j

   dim typename

   typename=""
   if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
   end if
   dim sql
   dim rs
   dim rstype

   dim typesql
   dim typeid,typename1
   if not isEmpty(request("typeid")) then
    typeid=request("typeid")
   else
    typeid=0
   end if
%>

<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=GB2312" http-equiv=Content-Type><LINK
href="font.css" rel=stylesheet type=text/css>
<META content="Microsoft FrontPage 6.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 text=#000000 topMargin=0>


<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
  <TBODY>
  <TR>
    <TD
    style="PADDING-BOTTOM: 15px; PADDING-LEFT: 15px; PADDING-RIGHT: 15px; PADDING-TOP: 15px">

<%
 if request("userid123")="" then
 sql="select * from users order by id desc"
 else
 sql="select * from users where question='"&request("userid123")&"'"
 end if
 Set rs= Server.CreateObject("ADODB.Recordset")
 rs.open sql,conn,1,1
  if rs.eof and rs.bof then
       response.write "<p align='center'>你数据不存</p>"
   else
      totalPut=rs.recordcount
      totalPut=rs.recordcount
      if currentpage<1 then
          currentpage=1
      end if
      if (currentpage-1)*MaxPerPage>totalput then
       if (totalPut mod MaxPerPage)=0 then
         currentpage= totalPut \ MaxPerPage
       else
          currentpage= totalPut \ MaxPerPage + 1
       end if

      end if
       if currentPage=1 then
           showpage totalput,MaxPerPage,"Teachers.asp"
            showContent
            showpage totalput,MaxPerPage,"Teachers.asp"
       else
          if (currentPage-1)*MaxPerPage<totalPut then
            rs.move  (currentPage-1)*MaxPerPage
            dim bookmark
            bookmark=rs.bookmark
           showpage totalput,MaxPerPage,"Teachers.asp"
            showContent
             showpage totalput,MaxPerPage,"Teachers.asp"
        else
            currentPage=1
           showpage totalput,MaxPerPage,"Teachers.asp"
           showContent
           showpage totalput,MaxPerPage,"Teachers.asp"
          end if
       end if
   end if
   sub showContent
       dim i
       i=0

  %>

<div align="center">
<table border="1" borderColor="#000000" cellPadding="0"
style="border-collapse: collapse; border-bottom: medium none" width="50%" cellspacing="1">
    <tr>
                <td align="center">用户</a></td>
        <td align="center" bgcolor="#FF9933">姓名</a></td>
    </tr>
<%do while not rs.eof%>
    <tr>
                <td align="center"><%=rs("userid")%></td>
        <td align="center" bgcolor="#FF9933"><%=rs("question")%></td>
    </tr>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</TD></TR></TABLE>
</div>
<%
   end sub

function showpage(totalnumber,maxperpage,filename)
  dim n
  if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
  else
     n= totalnumber \ maxperpage+1
  end if
  response.write "<p align=""center""><form method=Post action="&filename&"?typeid="&typeid&">"
    if CurrentPage<2 then
    response.write "<font color='#000080'>首页 上一页</font>&nbsp;"
  else
    response.write "<a href="&filename&"?page=1&typeid="&typeid&">首页</a>&nbsp;"
    response.write "<a href="&filename&"?page="&CurrentPage-1&"&typeid="&typeid&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
    response.write "<font color='#000080'>下一页 尾页</font>"
  else
    response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&typeid="&typeid&">"
    response.write "下一页</a> <a href="&filename&"?page="&n&"&typeid="&typeid&">尾页</a>"
  end if
   response.write "<font color='#000080'>&nbsp;页次:</font><strong><font color=red>"&CurrentPage&"</font><font  
color='#000080'>/"&n&"</strong>页</font> "
    response.write "<font color='#000080'>&nbsp;共<font color=red><b>"&totalnumber&"</b></font>个&nbsp;&nbsp;<b>用
户"&maxperpage&"</b>个/每页</font> "
   response.write " <font color='#000080'>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput  
value="&currentpage&">"
   response.write " <input class=buttonface type='submit'  value='Goto'  name='cndok'></span></p></form></p>"
end function
   rs.close
   set rs=nothing
   conn.close
   set conn=nothing
  %>
</BODY></HTML>
2010-12-05 02:27
快速回复:如何同时读取本ID和下一个ID内容
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017689 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved