Re: [問題] ASP網頁表格問題
※ 引述《TM1 ( )》之銘言:
: ASP 程式中用 VBscript 畫表格,如:
: <%
: response.write("<tr><td>xxxxx</td></tr>")
: %>
: xxxxx 是連結資料庫讀出的內容
: 因為需要挑選前 10 筆資料且表格排序方式為:
: ┌─┬─┐
: │1 │6 │
: ├─┼─┤
: │2 │7 │
: ├─┼─┤
: │3 │8 │
: ├─┼─┤
: │4 │9 │
: ├─┼─┤
: │5 │10│
: └─┴─┘
先寫好 function
註:n=第幾筆
function fun1(n)
str1=""
connStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
Server.MapPath( "data.mdb" )
set conn1 = Server.CreateObject("ADODB.Connection")
Set rs1 = Server.CreateObject("ADODB.Recordset")
conn1.Open connStr1
sql="select * from data1"
rs1.Open sql, conn1, 1, 3
rs1.requery
i=0
while not rs1.eof
i=i+1
if i = n then
str1=rs1("conetnt")
end if
rs1.movenext
wend
rs1.close
set rs1 = nothing
conn1.close
set conn1 = nothing
fun1 = str1
end function
再用網頁去叫
<table>
<%for i =1 to 5%>
<tr>
<td><%=fun1(i)%></td> <td><%=fun1(i+5)%></td>
</tr>
<%next%>
</table>
: 請問該如何辦到? 因為是用迴圈跑的關係現在只能作到:
: ┌─┬─┐
: │1 │2 │
: ├─┼─┤
: │3 │4 │
: ├─┼─┤
: │5 │6 │
: ├─┼─┤
: │7 │8 │
: ├─┼─┤
: │9 │10│
: └─┴─┘
: 希望有大大可以教教我方法.....謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.46.223.67
討論串 (同標題文章)