?? mgquestion.asp
字號:
<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<%
dim isedit '是否在修改狀態
dim color '表格顏色
dim sql,rs
dim subjectname
dim number '每頁顯示的文章數目
dim curpage, i,page
subjectname=trim(request("subjectname"))
color=1
function invert(str)
invert=replace(replace(replace(replace(str,"<","<"),">",">"),"<br>",chr(13))," "," ")
end function
number=5 '顯示試題數默認值
isedit=false
if request("action")="edit" then
isedit=true
end if
if request("action")="del" then '刪除
sql="delete from question where id=" &request("id")
conn.execute sql
%>
<script language=vbscript>
msgbox "操作成功!!該試題已刪除!"
</script>
<% end if
%>
<html>
<head>
<title>管理試題</title>
</head>
<body background=../images/backimage.gif >
<script language=javascript>
function SureDel(id,subjectname)
{
if ( confirm("你是否真的要刪除該試題?"))
{
window.location.href = "mgquestion.asp?action=del&id="+id+"&subjectname="+subjectname
}
}
</script>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from question where subjectname='" & cstr(trim(request("subjectname"))) & "' order by id desc ",conn,1,1
if err.number <> 0 then
response.write "數據庫出錯"
else
if rs.bof and rs.eof then
rs.close
response.write "該科目沒有試題"
else
%>
<table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" height="44" bordercolor=blue>
<tr>
<td width="20%"><div align="center">問題</div></td>
<td width="10%"> <div align="center">選項A</div></td>
<td width="10%"> <div align="center">選項B</div></td>
<td width="10%"> <div align="center">選項C</div></td>
<td width="10%"> <div align="center">選項D</div></td>
<td width="10%"> <div align="center">答案</div></td>
<td width="10%"> <div align="center">題型</div></td>
<td width="10%"> <div align="center">科目</div></td>
<td width="10%"> <div align="center">操作</div></td>
</tr> <%
if request("page")="" then
curpage = 1
else
curpage = cint(request("page"))
end if
rs.pagesize=cint(number)
rs.absolutepage = curpage
for i = 1 to rs.pagesize
%><tr>
<td width="20%" height="23" >
<div align="center"><%=rs("question")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("A")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("B")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("C")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("D")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("answer")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("type")%></div></td>
<td width="10%" height="23" >
<div align="center"><%=rs("subjectname")%></div></td>
<td width=10%" height="23" >
<div align="center">
<a href='mgquestion.asp?type=<%=trim(rs("type"))%>&subjectname=<%=trim(rs("subjectname"))%>&action=edit&id=<%= trim(rs("id"))%>&page=<%=request("page")%>'>編輯</a> <a href='javascript:SureDel(<%=rs("id") %>)'>刪除</a></div></td>
</tr>
<% rs.movenext
color=color+1
if rs.eof then
i = i + 1
exit for
end if
next %>
</table>
<% response.write "<hr size=0 width='100%'><div align=center>"
response.write "第<font color=red>" + cstr(curpage) + "</font>頁/共<font color=red>" + cstr(rs.pagecount) + "</font>頁 "
response.write "本頁<font color=red>" + cstr(i-1) + "</font>條/共<font color=red>" + cstr(rs.recordcount) + "</font>條 "
if curpage = 1 then
else
response.write "<a href='mgquestion.asp?type=" & cstr(request("type")) & "&subjectname=" & cstr(request("subjectname")) & "&page=1'>首頁</a> <a href='mgquestion.asp?type=" & cstr(request("type")) & "&subjectname=" & cstr(request("subjectname"))& "&page=" & cstr(curpage-1) & "'>前頁</a> "
end if
if curpage = rs.pagecount then
else
response.write "<a href='mgquestion.asp?type=" & cstr(request("type"))& "&subjectname=" & cstr(request("subjectname")) & "&page=" + cstr(curpage+1) + "'>后頁</a> <a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) + "&page=" + cstr(rs.pagecount) + "'>末頁</a>"
end if
end If
end if
'rs.close
set rs=nothing
%>
<hr size=0 width=100%></div>
<% if isedit then
set rs=server.createobject("adodb.recordset")
rs.open "select * from question where id=" & cstr(request("id")),conn,1,1
response.write "<p align='center'><font size=3>編 輯 試 題</font></p>"
else
response.write "<p align='center'><font size=3>添 加 試 題</font></p>"
end if %>
<form action="addquestion.asp" method="post">
<input type="Hidden" name="action" value='<% If isedit then%>modify<% Else %>add<% End If %>'>
<input type="Hidden" name="id" value='<%=request("id")%>'>
<input type="Hidden" name="page" value='<%=request("page")%>'>
<p align=center><font color=red size=+0>帶*各項均必須完全填寫</font></p>
<p align="left"><font color=red>*</font>問題:
<input type="text" name="question" class=input maxlength=100 size="50" value='
<% if isedit then
response.write trim(rs("question"))
end if %>'>
</p>
<p align="left"><font color=red>*</font>科目:
<input type="text" name="subjectname" class=input maxlength=30 size="10" value='
<% if isedit then
response.write trim(rs("subjectname"))
end if %>'>
</p>
<p align="left">
選項A:<input type="text" name="A" class=input maxlength=15 size="10" value='
<% if isedit then
response.write trim(rs("A"))
end if %>'>
選項B<input type="text" name="B" class=input maxlength=15 size="10" value='
<% if isedit then
response.write trim(rs("B"))
end if %>'>
選項C<input type="text" name="C" class=input maxlength=15 size="10" value='
<% if isedit then
response.write trim(rs("C"))
end if %>'>
選項D<input type="text" name="D" class=input maxlength=15 size="10" value='
<% if isedit then
response.write trim(rs("D"))
end if %>'>
</p>
<p align="left"><font color=red>*</font>答案(請填寫選項的字母):
<input type="text" name="answer" class=input maxlength=15 size="10" value='
<% if isedit then
response.write trim(rs("answer"))
end if %>'>
</p>
<p align="left"><font color=red>*</font>類型(單選題還是多選題):<input type="radio" name="leixing" value="單選題"
<% if isedit then
if rs("type")="單選題" then
response.write "checked"
end if
end if %>>單選題       
<input type="radio" name="leixing" value="多選題"
<% if isedit then
if rs("type")="多選題" then
response.write "checked"
end if
end if
%>>多選題</p>
<p align="center"><input type=submit value=" 確 認 " class=button></p>
</form>
<p align=center><a href="primarypage.asp"><font color=red size=+0 face=宋體>返回管理界面</font></a></p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -