日期:2014-05-16  浏览次数:20892 次

asp查询结果显示多行
<%if request.Form("Submit2") <> "" or  Request.Form("jztel2")<>""  then
if   Request.Form("jztel2")="" then
   response.write"<script>alert('您输入表单资料是空的!');history.go(-1)</script>"  response.end
else   
if request.Form("Submit2") <> "" or Request.Form("jztel2") <> "" then       sql="select * from tab1 where 电话_户名 like  '"&Request.Form("jztel2")&"%' order by 受理时间 desc"       
call q(sql)   
end if   
end if
end  if         %>
tab1表里有很多字段联系电话1,联系电话2,姓名,工号,所在地,类型,分类,故障,现象,公告,明细,统计等,这样查询出来的结果只能显示在一行上,字段多了,显示的效果不好看,请问怎么改代码,查询的结果可以显示多行,每行就几个字段!麻烦写出代码谢谢!
------解决方案--------------------
<%
 sub q(inputquery)
 connstr="driver={Microsoft Access Driver (*.mdb)};DBQ=" &Server.MapPath("mydb.mdb")
 set cn=server.createobject("adodb.connection")
 cn.open connstr
 set rstemp=cn.execute(inputquery)
 howmanyfields=rstemp.fields.count-1
 %>

 <% for i=0 to howmanyfields%>
联系电话1:<%=rstemp("联系电话1")%> 联系电话2:<%=rstemp("联系电话2")%> 姓名<%=rstemp("姓名")%> 工号<%=rstemp("工号")%>。。。。中间自己加。。。。 明细:<%=rstemp("明细")%>
 <% next %>
 
 111222
 <%
 response.write("<br>受理总数:" & count)
 rstemp.close
 set rstemp=nothing
 cn.close
 set cn=nothing
 end sub
 %> 
 注:《%=rstemp("这里改成你的真实字段就行了")%》
 %>