用循环做课程表输出表格

80酷酷网    80kuku.com

  循环最近在做一个实验、机房预约系统,最开始用的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></table>")
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 line-width: 20; vertical-align: top> <font 班级</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

%>
</table>



效果图


单元格内的数字通过两个数字来定位,以数字为查询条件,即可从数据库中查询,并显示出来!

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: