潍坊君豪国际大酒店:在ASP中怎么横向显示记录?急急急~~~~

来源:百度文库 编辑:神马品牌网 时间:2024/05/06 10:33:37
在ASP中怎么横向显示记录?
问题1.我想每行显示2条记录,只显示一行怎么写,请大家帮助!
问题2.另:如果每行显示2条记录,总共显示3行怎么写~~~~
--------------------------------------------------------
问题1希望显示效果为:·记录1 | · 记录2
---------------------------------------------------------------
问题2希望显示效果为:·记录1 | · 记录2
·记录3 | · 记录4
·记录5 | · 记录6
------------------------------------------------------------
请大侠回答具体点,小弟太菜了!

Public Sub adlist(num,sid,eid,pwidth,pheight,n,tpwz)
Response.write ("<table width=100% cellspacing=0 cellpadding=0 border=0 >")
Sqlad = "Select top "&num&" ad_id,ad_name,ad_piccount,ad_pic,ad_link from articlelch_ad where "
Sqlad =Sqlad& "ad_id >= "&sid&" and ad_id<="&eid&" order by ad_id asc"
set Rsad = conn.execute(Sqlad)
if Rsad.eof and rsad.bof then
Response.write "<div align=center>还没有任何广告。</div>"
else
do while not Rsad.eof
Response.write "<tr>"
for i = 1 to n
Response.write "<td align=center width="&pwidth&">"
if tpwz=1 then
if rsad("ad_piccount")>0 then
response.write ("<a href="&rsad("ad_link")&" target=_blank>"&replace(rsad("ad_pic"),"width=200 height=100 "," width="& pwidth &" height="& pheight &"")&"</a>")
else
response.write("<a href="&rsad("ad_link")&" target=_blank>"&rsad("ad_name")&"</a>")
end if
else
response.write("<a href="&rsad("ad_link")&" target=_blank>"&rsad("ad_name")&"</a>")
end if
Response.write "</td>"
Rsad.movenext
if rsad.eof then exit for
next
Response.write "</tr>"
loop

Response.write "</table>"
end if
Rsad.close

end sub
这个是我曾经弄的一个显示广告的代码,你看看!
num代表总查询的记录数
sid起始ID
eid结束ID
pwidth,pheight广告图片宽和高
n每行记录数
tpwz显示内容长度。
你的第一个问题就是把N设为2,第二个问题就是把NUM设为6,N设为2。

<script language="vbscript">
dim n,i
document.write("<table width='300px' border='1'>")
document.write("<tr>")
for n=1 to 50
document.write("<td width='50pt'>"&n&"</td>")
i=i+1
if (i mod 5=0) then
document.write("</tr></tr>")
end if
next
document.write("<tr>")
document.write("<table>")
</script>
运行这段代码看看
if (i mod 5=0) then 中的5表示一行5个,你想一行2个换成2就行!

支持rows,cols,以及翻页显示的!中间是数据显示部分!
把那块代码换成你要的就OK了,你想怎么显示就怎么显示!
showNews "select * from news",3(行),3(列),1(页),1(显示书签),20(所有项中数据显示长度为20个字符)
使用我的代码再来跟我要 autoCut()函数吧!
<%
sub showNews(sql,rows,cols,ipage,isShowBookMark,autoLen)
dim rs,page_size,icol,path
if cols="" or not isNumeric(cols) then cols = 1
if cols<=0 then cols = 1
if rows="" or not isNumeric(rows) then rows = 1
if rows<=0 then rows=1
if ipage="" or not isNumeric(ipage) then ipage=1
if ipage<=0 then ipage=1
if autoLen="" or not isNumeric(autoLen) then autoLen = 20
if autoLen<=0 then autoLen = 20

page_size = cols * rows
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
response.write "<table width=100% border=0 cellpadding=0 cellspacing=0 id=news>" & VBCRLF
if rs.eof or rs.bof then
response.write "<tr><td width=100% height=50 align=center valign=middle style='color:red'>暂时没有信息!</tr>" & VBCRLF
response.write "</table>" & VBCRLF
exit sub
end if
rs.pageSize = page_size
if int(ipage) > int(rs.pageCount) then ipage = rs.pageCount
rs.absolutePage = ipage

icol = 0
while not rs.eof and int(icol)<int(page_size)
if icol mod cols = 0 then
response.write "<tr>" & VBCRLF
end if
response.write "<td width=" & int(100/cols) & "% height=20 align=left valign=middle>" & VBCRLF
%>
<!数据显示开始>  ·<a href="readData.asp?id=<%=rs("id")%>&DataType=10001" target="_self"><%=autoCut(rs("title"),autoLen)%></a> <span id="time">[<%=DateValue(rs("post_time"))%>](已阅<%=rs("click_count")%>次)</span>
<!结束>
<%
response.write "</td>" & VBCRLF
icol = icol + 1
if icol mod cols = 0 then
response.write "</tr>" & VBCRLF
end if
rs.movenext
wend
if icol mod cols <> 0 then
response.write "<td colspan=" & int(cols - icol mod cols) & "> </td></tr>" & VBCRLF
end if
response.write "</table>"

if isShowBookMark=1 then

dim reg
set reg = new RegExp
reg.pattern = "[&]*page=[0-9]*"
reg.Global = true
reg.Ignorecase = true
path = reg.replace(request.QueryString,"")
if path="" then
path = "?" & path
else
path = "?" & path & "&"
end if
set reg = nothing

response.Write "<br><div style='font-size:12px;color:black'>" & VBCRLF
response.write "<br>总记录数<span style='color:red'>"&rs.recordCount&"</span>   每页<span style='color:red'>" & page_size & "</span>  "
if ipage <= 1 then
response.write "<span style='color:darkgray'>首页 前页</span>"
else
response.write "<a href=" & path & "page=1>首页</a> <a href=" & path & "page="&ipage-1&">前页</a>"
end if
if int(ipage) = int(rs.pageCount) then
response.write "<span style='color:darkgray'> 下页 末页</span>"
else
response.write " <a href=" & path & "page="&ipage+1&">下页</a> <a href=" & path & "page="&rs.pageCount&">末页</a>"
end if
response.write "    第"&ipage&"页 共"&rs.pageCount&"页"
response.write "</div>"

end if
end sub
%>

<%
set rs = 获取RecordSet
dim col
col = 1 '表示显示在第一列
%>
<table>
<%
while(not rs.eof)
if col = 1 then
%>
<tr><td>·<%=rs('列名')%></td>
<%
col = 2
else if col = 2 then
%>
<td>·<%=rs('列名')%></td></tr>
<%
col = 1
end if
%>
rs.movenext
wend
if col = 2 then //如果只填充了表格左边,则右边有空格填充
%>
<td> </td></tr>
<%
end if
%>
</table>

我写的是问题2的解答,如果你看懂了,写出第一种效果不是问题了.

这是我现场写的,没调试,看过别人的答案,我的最符合你要求的,不过用了要调试,呵呵