asp怎样把数据分成两列显示?
<%FunctiongInfo(c1,c2,c3,s)IfNotIsObject(Conn)orConnIsNothingThenDBLinkDimTempText,sq...
<%
Function gInfo(c1,c2,c3,s)
If Not IsObject(Conn) or Conn Is Nothing Then DBLink
Dim TempText,sql,c,t
t=" top "&s&" "
if c3>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2&" and city_threeid="&c3
elseif c2>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2
elseif c1>0 Then
c=" and city_oneid="&c1
end if
sql="select "&t&" adid,title,color,time,type_one,xxlx,city_one,city_two,city_three,date,text,username,tel,pic from china_data where mark='yes' and xxlx=1"&c&" order by time desc"
Set Rs=conn.execute(sql)
if Rs.eof Then
TempText=TempText&"<table width=""100%"" align=""left""><tr><td align=""left"">暂无"
IF c1>0 Then TempText=TempText&conn.Execute("Select city From china_city Where id="&c1&" and twoid="&c2&" and threeid="&c3&"")(0)
TempText=TempText&"供应信息! </td></tr></table>"
else
do while not rs.eof
TempText=TempText&"<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" onMouseOver=""borderize_on(event)"" onMouseOut=""borderize_off(event)"" class=""zuo22"" onclick=""javascript:clickfun('123')"">"
TempText=TempText& "<tr><td width=""20"" align=""center"" height=""25"" style=""border-bottom:1px #e6e6e6 dashed""><img src=""Images/gq.jpg""/>"
TempText=TempText&"</td>"
TempText=TempText&"<td width=""100"" align=""center"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">【"&rs(4)&"】</td><td width=""220"" style=""border-bottom:1px #e6e6e6 dashed"">"
if Len(rs(1))>=8 then
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&Left(rs(1),15)&""
else
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&rs(1)&"</a>"
end if
TempText=TempText&"<td width=""110"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
TempText=TempText&"<img src=""Images/tel.gif"" width=""16"" height=""14"">:"&rs(12)&"</td>"
TempText=TempText&"<td width=""120"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
if rs(8)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""&rs(8)&""
elseif rs(7)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""
else
TempText=TempText&""&rs(6)&""
end if
TempText=TempText&"</td>"
TempText=TempText&"</td><td width=60 align=""right"" style=""border-bottom:1px #e6e6e6 dashed"">"&rs(9)&"</td></tr>"
rs.movenext
loop
TempText=TempText&"</table></div>"
Rs.Close:Set Rs=nothing
end if
gInfo=TempText
End Function 展开
Function gInfo(c1,c2,c3,s)
If Not IsObject(Conn) or Conn Is Nothing Then DBLink
Dim TempText,sql,c,t
t=" top "&s&" "
if c3>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2&" and city_threeid="&c3
elseif c2>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2
elseif c1>0 Then
c=" and city_oneid="&c1
end if
sql="select "&t&" adid,title,color,time,type_one,xxlx,city_one,city_two,city_three,date,text,username,tel,pic from china_data where mark='yes' and xxlx=1"&c&" order by time desc"
Set Rs=conn.execute(sql)
if Rs.eof Then
TempText=TempText&"<table width=""100%"" align=""left""><tr><td align=""left"">暂无"
IF c1>0 Then TempText=TempText&conn.Execute("Select city From china_city Where id="&c1&" and twoid="&c2&" and threeid="&c3&"")(0)
TempText=TempText&"供应信息! </td></tr></table>"
else
do while not rs.eof
TempText=TempText&"<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" onMouseOver=""borderize_on(event)"" onMouseOut=""borderize_off(event)"" class=""zuo22"" onclick=""javascript:clickfun('123')"">"
TempText=TempText& "<tr><td width=""20"" align=""center"" height=""25"" style=""border-bottom:1px #e6e6e6 dashed""><img src=""Images/gq.jpg""/>"
TempText=TempText&"</td>"
TempText=TempText&"<td width=""100"" align=""center"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">【"&rs(4)&"】</td><td width=""220"" style=""border-bottom:1px #e6e6e6 dashed"">"
if Len(rs(1))>=8 then
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&Left(rs(1),15)&""
else
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&rs(1)&"</a>"
end if
TempText=TempText&"<td width=""110"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
TempText=TempText&"<img src=""Images/tel.gif"" width=""16"" height=""14"">:"&rs(12)&"</td>"
TempText=TempText&"<td width=""120"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
if rs(8)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""&rs(8)&""
elseif rs(7)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""
else
TempText=TempText&""&rs(6)&""
end if
TempText=TempText&"</td>"
TempText=TempText&"</td><td width=60 align=""right"" style=""border-bottom:1px #e6e6e6 dashed"">"&rs(9)&"</td></tr>"
rs.movenext
loop
TempText=TempText&"</table></div>"
Rs.Close:Set Rs=nothing
end if
gInfo=TempText
End Function 展开
2个回答
展开全部
试试下面我改动的,改动过的地方都有注释说明:
<%
Function gInfo(c1,c2,c3,s)
If Not IsObject(Conn) or Conn Is Nothing Then DBLink
Dim TempText,sql,c,t
t=" top "&s&" "
if c3>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2&" and city_threeid="&c3
elseif c2>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2
elseif c1>0 Then
c=" and city_oneid="&c1
end if
sql="select "&t&" adid,title,color,time,type_one,xxlx,city_one,city_two,city_three,date,text,username,tel,pic from china_data where mark='yes' and xxlx=1"&c&" order by time desc"
Set Rs=conn.execute(sql)
if Rs.eof Then
TempText=TempText&"<table width=""100%"" align=""left""><tr><td align=""left"">暂无"
IF c1>0 Then TempText=TempText&conn.Execute("Select city From china_city Where id="&c1&" and twoid="&c2&" and threeid="&c3&"")(0)
TempText=TempText&"供应信息! </td></tr></table>"
else
'下面二行是增加的
TempText=TempText&"<table><tr>"
Dim N:N=1
do while not rs.eof
'下面一行有改动开头增加了<td>
TempText=TempText&"<td><table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" onMouseOver=""borderize_on(event)"" onMouseOut=""borderize_off(event)"" class=""zuo22"" onclick=""javascript:clickfun('123')"">"
TempText=TempText& "<tr><td width=""20"" align=""center"" height=""25"" style=""border-bottom:1px #e6e6e6 dashed""><img src=""Images/gq.jpg""/>"
TempText=TempText&"</td>"
TempText=TempText&"<td width=""100"" align=""center"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">【"&rs(4)&"】</td><td width=""220"" style=""border-bottom:1px #e6e6e6 dashed"">"
if Len(rs(1))>=8 then
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&Left(rs(1),15)&""
else
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&rs(1)&"</a>"
end if
'下面新增加一行,增加了</td>
TempText=TempText&"</td>"
TempText=TempText&"<td width=""110"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
TempText=TempText&"<img src=""Images/tel.gif"" width=""16"" height=""14"">:"&rs(12)&"</td>"
TempText=TempText&"<td width=""120"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
if rs(8)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""&rs(8)&""
elseif rs(7)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""
else
TempText=TempText&""&rs(6)&""
end if
TempText=TempText&"</td>"
'下面一行有改动,删除多余的</td>,结尾的</tr>后增加</table></td>两个标签
TempText=TempText&"<td width=60 align=""right"" style=""border-bottom:1px #e6e6e6 dashed"">"&rs(9)&"</td></tr></table></td>"
'下面三行是增加的,用于换行
If N Mod 2 = 0 Then TempText=TempText&"</tr><tr>"
N = N+1
TempText=TempText&"</table>"
rs.movenext
loop
'下面一行注释掉
'TempText=TempText&"</table></div>"
Rs.Close:Set Rs=nothing
end if
gInfo=TempText
End Function
%>
你也可以参考一下这个例子:
http://zhidao.baidu.com/question/118583833.html
<%
Function gInfo(c1,c2,c3,s)
If Not IsObject(Conn) or Conn Is Nothing Then DBLink
Dim TempText,sql,c,t
t=" top "&s&" "
if c3>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2&" and city_threeid="&c3
elseif c2>0 then
c=" and city_oneid="&c1&" and city_twoid="&c2
elseif c1>0 Then
c=" and city_oneid="&c1
end if
sql="select "&t&" adid,title,color,time,type_one,xxlx,city_one,city_two,city_three,date,text,username,tel,pic from china_data where mark='yes' and xxlx=1"&c&" order by time desc"
Set Rs=conn.execute(sql)
if Rs.eof Then
TempText=TempText&"<table width=""100%"" align=""left""><tr><td align=""left"">暂无"
IF c1>0 Then TempText=TempText&conn.Execute("Select city From china_city Where id="&c1&" and twoid="&c2&" and threeid="&c3&"")(0)
TempText=TempText&"供应信息! </td></tr></table>"
else
'下面二行是增加的
TempText=TempText&"<table><tr>"
Dim N:N=1
do while not rs.eof
'下面一行有改动开头增加了<td>
TempText=TempText&"<td><table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" onMouseOver=""borderize_on(event)"" onMouseOut=""borderize_off(event)"" class=""zuo22"" onclick=""javascript:clickfun('123')"">"
TempText=TempText& "<tr><td width=""20"" align=""center"" height=""25"" style=""border-bottom:1px #e6e6e6 dashed""><img src=""Images/gq.jpg""/>"
TempText=TempText&"</td>"
TempText=TempText&"<td width=""100"" align=""center"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">【"&rs(4)&"】</td><td width=""220"" style=""border-bottom:1px #e6e6e6 dashed"">"
if Len(rs(1))>=8 then
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&Left(rs(1),15)&""
else
TempText=TempText&"<a href=""show.asp?id="&rs(0)&""" title="""&rs(1)&""" target=""_blank"">"&rs(1)&"</a>"
end if
'下面新增加一行,增加了</td>
TempText=TempText&"</td>"
TempText=TempText&"<td width=""110"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
TempText=TempText&"<img src=""Images/tel.gif"" width=""16"" height=""14"">:"&rs(12)&"</td>"
TempText=TempText&"<td width=""120"" align=""left"" vlign=""middle"" style=""border-bottom:1px #e6e6e6 dashed"">"
if rs(8)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""&rs(8)&""
elseif rs(7)<>"" then
TempText=TempText&""&rs(6)&""&rs(7)&""
else
TempText=TempText&""&rs(6)&""
end if
TempText=TempText&"</td>"
'下面一行有改动,删除多余的</td>,结尾的</tr>后增加</table></td>两个标签
TempText=TempText&"<td width=60 align=""right"" style=""border-bottom:1px #e6e6e6 dashed"">"&rs(9)&"</td></tr></table></td>"
'下面三行是增加的,用于换行
If N Mod 2 = 0 Then TempText=TempText&"</tr><tr>"
N = N+1
TempText=TempText&"</table>"
rs.movenext
loop
'下面一行注释掉
'TempText=TempText&"</table></div>"
Rs.Close:Set Rs=nothing
end if
gInfo=TempText
End Function
%>
你也可以参考一下这个例子:
http://zhidao.baidu.com/question/118583833.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询