标题:如何同时显示两个表的内容,两个表结构一样
只看楼主
zhongxuewei
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-1-25
结帖率:0
已结贴  问题点数:20 回复次数:7 
如何同时显示两个表的内容,两个表结构一样
我的代码如下.麻烦高手帮忙改一下

表1: wlw_wlss  表二:gd56_wlw_wlss    结构是一样的,我想同时调用这两个表的内容

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

    Set rss=Server.CreateObject("ADODB.Recordset")
    strSql ="select * from wlw_wlss  where username='"&user&"' order by fdate desc,id desc "
    rss.Open strSql,db,1,1
    if not rss.bof and not rss.eof then
        If Request("fid")="" Then   
            page_no=1
        Else
            page_no=Cint(Request("fid"))  
        End If
        
        rss.PageSize=10                        
        rss.AbsolutePage=page_no  
        
       %><tr>
            <td width="57%" bgcolor="#E8E8E8"><strong>&nbsp;&nbsp;&nbsp;&nbsp;专线标题</strong></td>
            <td width="25%" bgcolor="#E8E8E8"><div align="center"><strong>专线类型</strong></div></td>
            <td width="18%" bgcolor="#E8E8E8"><div align="center"><strong>发布日期</strong></div></td>
          </tr>
           <%
        I=rss.PageSize   
        do while not rss.eof  And I>0                  
            I=I-1
       %><tr>
            <td height="25">&nbsp;&nbsp;&nbsp;&nbsp;<a href="zx_ss.asp?user=<%=user%>&id=<%=rss("id")%>" target="_blank" ><%=left(rss("title"),36)%></a></td>
            <td><div align="center">
              
            </div></td>
            <td><div align="center"><%=rss("fdate")%></div></td>
          </tr> <%
            rss.movenext
            loop
         %>
          <tr>
            <td colspan="3"><div align="center">共<%=rss.recordcount%>条&nbsp; 每页<%=rss.pagesize%>条&nbsp;&nbsp; <%=page_no%>/<%=rss.pagecount%>&nbsp;&nbsp;
                    <%
        if rss.pagecount<>1 then
        if page_no=1 then
        response.write "首页&nbsp;&nbsp;&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;&nbsp;"
        else
        %>                    <a href="?fid=<%=1%>&user=<%=user%>">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="?fid=<%=page_no-1%>&user=<%=user%>">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
                    <%
        end if
        if page_no=rss.pagecount then
        response.write "下一页&nbsp;&nbsp;&nbsp;&nbsp;尾页"
        else
        %>&nbsp;&nbsp;&nbsp;&nbsp;<a href="?fid=<%=page_no+1%>&user=<%=user%>">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="?fid=<%=rss.pagecount%>&user=<%=user%>">尾页</a>
                <%
          end if
          end if
    %>              </div><%else%>      <!--#include file="inc/ssnot.asp"--><% end if
          rss.close
        %><br /></tr></td>
            
        </table>
 
搜索更多相关主题的帖子: Request 
2011-01-26 11:07
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
得分:5 
回复 楼主 zhongxuewei
我现在用着的代码。有分页,能调入二个表,供你参考:
<!--#include file="conn.asp"-->
<%
   MaxPerPage=100
   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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="font.css" rel="stylesheet">
<title>你现在的位置----会员</title>
</head>
<%
 if request("dj")<>"" then
sql="select * from scunews where level="&request("dj")&" order by id asc"
else
sql="select * from scunews  order by id asc"
end if
 Set rs= Server.CreateObject("ADODB.Recordset")
 rs.open sql,conn,1,1
set rs1=server.createobject("adodb.recordset")
sql1="select * from users2"
rs1.open sql1,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,"index.asp"
            showContent
            showpage totalput,MaxPerPage,"index.asp"
       else
          if (currentPage-1)*MaxPerPage<totalPut then
            rs.move  (currentPage-1)*MaxPerPage
            dim bookmark
            bookmark=rs.bookmark
           showpage totalput,MaxPerPage,"index.asp"
            showContent
             showpage totalput,MaxPerPage,"index.asp"
        else
            currentPage=1
           showpage totalput,MaxPerPage,"index.asp"
           showContent
           showpage totalput,MaxPerPage,"index.asp"
          end if
       end if
   end if
   sub showContent
       dim i
       i=0
  %>
<table border="1" borderColor="#000000" cellPadding="0"
style="border-collapse: collapse; border-bottom: medium none" width="981" cellspacing="1" id="table2">
<%do while not rs.eof%>
 <tr>
    <td align="center" bgcolor="#FFCCFF" height="18" width="326">
     </td>
    <td align="center" bgcolor="#FFCCFF" height="18" width="326"><%=rs1("userid")%>
    </td>
    <td align="center" bgcolor="#FFFFFF" height="18" width="326">
    <a target="_top" href="4.asp?id=4"><font color="#FF0000"><%=rs("Q2users1")%></a></font></td>
  </tr>
  <% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
rs1.movenext
loop
%>
 </table>  
<%
   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&"?id="&request("id")&">"
    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&"&id="&request("id")&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
    response.write "<font color='#000080'>下一页 尾页</font>"
  else
    response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&id="&request("id")&">"
    response.write "下一页</a> <a href="&filename&"?page="&n&"&id="&request("id")&" >尾页</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;会员:<b>"&totalnumber&"</b>个 &nbsp;&nbsp;你所在页:"&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='输入页数翻页'  name='cndok'></span></p></form>"
end function
   rs.close
   set rs=nothing
   conn.close
   set conn=nothing
  %>
2011-01-26 14:26
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:5 
showpage totalput,MaxPerPage,"index.asp"
这句应该是调用过程,而你下面的是个函数
楼上的代码能正常使用?

QQ:63572063
2011-01-26 21:29
kangli_kl
Rank: 6Rank: 6
等 级:侠之大者
威 望:2
帖 子:134
专家分:489
注 册:2008-4-5
得分:5 
要想在一个页面里操作两个表,创建两个ADODB.recordset对象即可,如:
表一:
Set rs1=Server.CreateObject("ADODB.Recordset")
    strSql1 ="select * from tb1 where ……"
    rs1.Open strSql1,db,1,1
    你的操作……
表二:
Set rs2=Server.CreateObject("ADODB.Recordset")
    strSql2 ="select * from tb2 where ……"
    rs2.Open strSql2,db,1,1
    你的操作……

求上而得中,求中而得下。
2011-01-27 10:40
hebss
Rank: 2
等 级:论坛游民
帖 子:19
专家分:23
注 册:2009-10-12
得分:5 
回复 2楼 a190066
有一个表只能显示第一页,希望解决一下

[url=www.]www.[/url]   [url=www.]www.[/url]
2011-01-29 14:46
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
得分:0 
回复 5楼 hebss
是你其中一个表的ID数不同。我现在的表。二个表的ID数要一样的。
2011-01-30 00:27
hebss
Rank: 2
等 级:论坛游民
帖 子:19
专家分:23
注 册:2009-10-12
得分:0 
回复 6楼 a190066
希望你能解决一下,我也在找这样的代码,麻烦你了,谢谢

[url=www.]www.[/url]   [url=www.]www.[/url]
2011-01-31 09:15
zhongx
Rank: 2
等 级:论坛游民
威 望:1
帖 子:370
专家分:42
注 册:2007-8-16
得分:0 
bdfef

感动常在,每天进步一点点,开心学习在编程论坛。
http://www.
2011-02-09 18:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-331586-1-1.html




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

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