📄 make.asp
字号:
<%
'实现页面运行时间记录
dim startime
startime=timer()
%>
<%
dim morecourse(70)'记录哪个地方还存在没输出完的课程
dim usedid(70) '定义一个全局数组,用来记录被占用了的课程id
dim tabletimed '定义一个全局数,用来记录是第几次绘制表格
'初始化
tabletimed=1
for t=0 to 70
usedid(t)=0
morecourse(t)=0
next
%>
<%
function check_more_cousearray()'定义检查数组函数
for i=0 to 70
if morecourse(i)=1 then
check_more_cousearray=1
Exit For
end if
next
end function
%>
<%
function drawtable(ntime)'这里定义一个通用过程,绘制表格函数
'传入的这个ntime是要绘制第几个表格
'注意到运用request全局变量
'输出表头--------------------------------------
response.write("<table width='645' border='1' align='center' cellpadding='0' cellspacing='0' > <tr bgcolor='#FFFF66'> <td colspan='6'><div align='center' > </div> </td> </tr> <tr bgcolor='#6699FF'> <td width='27'><div align='center' class='style1' >节</div></td> <td width='104'><div align='center' class='style1' >周一</div></td> <td width='117'><div align='center' class='style1'>周二</div></td> <td width='131'><div align='center' class='style1' >周三</div></td> <td width='136'><div align='center' class='style1' >周四</div></td> <td width='116'><div align='center' class='style1' >周五</div></td> </tr>")
'输出内容--------------------------------------
j=0'行号,其实就是节的编号
for i=1 to 70
if i mod 5=1 then
j=j+1 '行号开始计数
response.write "<tr height=30>" '行起始
response.write "<td bgcolor='#99FF66'><div align='center' class='style1'>"&j&"</div></td>"'书写行号
end if
response.write drawmycourse(i)'绘制该时间表格的课程
if i mod 5=0 then
response.write "</tr>" '行结束
end if
next
'输出结尾--------------------------------------
response.write("</table><br>")
end function
%>
<%
Function mysql(timeid)'传入的是时间id
temp=request(timeid)'获得临时数组
if temp="" then '若该时间内没课程,则赋予-1
temp=-1
end if
sql="select * from course where ID in(" & temp & ")"&" order by begin_week asc" '这个sql语句查询该时间段内的所选的所有课程
mysql=sql
End Function
%>
<%
Function drawmycourse(i)
'i是时间编号
'-----------------------
'首先检查这节课是否被安排了课程
if usedid(i)=1 then
Exit Function
end if
'-----------------------
'第二步构造一查询语句并开始查询
sql=mysql(i)
'下面开始查询
dim answerstring
rst.Open sql,my_conn,3,2 '得到搜索后的记录
'---------------------------------
'//下面开始输出:构建输出的字符串
if rst.EOF or rst.BOF then
answerstring="<td> </td>"
else
if rst.RecordCount<tabletimed then
answerstring="<td> </td>"
else
rst.move(tabletimed-1)'为何-1,因为编号是从0开始
rowspan=rst("end_time")-rst("begin_time")+1'计算出课程节数
answerstring="<td class=""style2""" & " rowspan=" & rowspan & ">"
answerstring=answerstring&rst("begin_week")&"-"&rst("end_week")&"周"&"<br>"&rst("name")&"<br>"&"地点:" & rst("where") & "</td>"'构建课程内容
'---------------------------------
'修改全局的标记数组
myii=i '似乎出现变量命名冲突,且生存期冲突,故临时命名变量
for myj=1 to rowspan
usedid(myii)=1'设置标志1为已经被安排了课程的时间
myii=myii+5'加5就到它对应的下面一节课的编号了
next
'---------------------------------
'输出完第一条记录后,检查个数,若有多余则做相应处理(先存起来)
if rst.RecordCount>tabletimed then
morecourse(i)=1'设置某时间还有剩余课程
end if
'----------------------------
end if
end if
'//下面关闭记录集
rst.close
drawmycourse=answerstring '返回select字符串
End Function
%>
<!--#include file="../database/opendb.asp"-->
<!--#include file="visitedcount.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="../bg/css.asp"-->
</head>
<body topmargin="0" leftmargin="0">
<% call drawtable(tabletimed)'第一个表格绘制%>
</body>
</html>
<%
'下面检查数组,然后循环进行输出表格
'------------------------------------
if check_more_cousearray() then '若检查有剩余,继续表格输出
'若第一个表格绘制后还有剩余,则进行循环检查绘制
Do While check_more_cousearray()
'先清空环境
for t=0 to 70
usedid(t)=0
morecourse(t)=0
next
tabletimed=tabletimed+1
drawtable(tabletimed)
loop
'最后绘制完关闭数据库连接对象
my_conn.close
set my_conn=nothing
'//---------------
else
'若无剩余,直接关闭数据库
my_conn.close
set my_conn=nothing
'//---------------
end if
%>
<%
dim endtime
endtime=timer()
%>
<br><span class="style1">课表制作完成,下面请另存为本地文件,用word打开进行编辑.</span>
<br>
<br><span class="style1">页面执行时间:<%=FormatNumber((endtime-startime)*1000,3)%>毫秒</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -