最近在做一個實驗、機房預約系統,最開始用的dreamwaver做的表格,很大,而且程序共有3000多行,很不方便管理和修改~
最近用循環和判斷做了一個輸出表格,源程序如下
<table border="1" cellspacing="0" bordercolor="#006699">
<% hang=41 '行變量 lie=9 '列變量 leirong=blie&" "&bhang for bhang=1 to hang response.write("<tr>") '------------------------------------------------控制星期開始 for blie=1 to lie if bhang=1 then if blie=1 then response.Write("<td colspan=2 width=108>第"&weektime&"周") else if not blie=9 then response.Write("<th width=93>") xqnotemp=blie-1 if xqnotemp=1 then xqno="一" if xqnotemp=2 then xqno="二" if xqnotemp=3 then xqno="三" if xqnotemp=4 then xqno="四" if xqnotemp=5 then xqno="五" if xqnotemp=6 then xqno="六" if xqnotemp=7 then xqno="日" response.Write("星期"&xqno) response.write("</th>") end if end if else if ((bhang+2) mod 4)=0 and blie=1 then response.Write("<td rowspan=4>"&(bhang+2)/4&"小節") response.Write(" ") response.write("<td>") response.write("實驗名稱") response.write("</td>") else if not blie=9 then '------------------------------控制實驗名稱、班級、任課教師內容開始 if (not blie=1) and ((bhang+2) mod 4=0) then response.write("<td rowspan=4>") response.write("<table><tr>") rs.open "select * from lesson",conn,1,1 ' response.write(rs("day")) rs.close response.write("<td></td></tr>") response.write(blie-1&" "&bhang) response.write("</td>") else '------------------------------顯示第二實驗名稱、班級、任課教師開始 if blie=1 then response.Write("<td width=63 algin="&"center"&">") if bhang mod 3=0 then response.write("<span style=line-height:2; line-width: 20; vertical-align: top> <font style=font-size:9pt> 班級</font></span>") elseif bhang mod 4=0 then response.write("任課教師") else response.write("人數") end if response.Write("</td>") end if '------------------------------顯示第二實驗名稱、班級、任課教師結束 end if '------------------------------控制實驗名稱、班級、任課教師內容結束 end if end if end if next '---------------------------------------------------控制星期結束 response.write("</tr>") next
%>
效果圖
單元格內的數字通過兩個數字來定位,以數字為查詢條件,即可從數據庫中查詢,并顯示出來!
|