📄 mgquestion.asp
字号:
<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="Checkadmin.asp"-->
<%
dim isedit '是否在修改状态
dim sql,rs
dim subjectname
dim number '每页显示的文章数目
dim curpage, i,page
subjectname=trim(request("subjectname"))
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"><font size="2">问题</font></div></td>
<td width="10%"> <div align="center"><font size="2">选项A</font></div></td>
<td width="10%"> <div align="center"><font size="2">选项B</font></div></td>
<td width="10%"> <div align="center"><font size="2">选项C</font></div></td>
<td width="10%"> <div align="center"><font size="2">选项D</font></div></td>
<td width="10%"> <div align="center"><font size="2">答案</font></div></td>
<td width="10%"> <div align="center"><font size="2">题型</font></div></td>
<td width="10%"> <div align="center"><font size="2">科目</font></div></td>
<td width="10%"> <div align="center"><font size="2">操作</font></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"><font size="2"><%=rs("question")%></font></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("A")%></font></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("B")%></font></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("C")%></font></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("D")%></font></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("answer")%></font></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("type")%></font></strong></div></td>
<td width="10%" height="23" >
<div align="center"><font size="2"><%=rs("subjectname")%></font></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")%>'><font size="2">编辑</font></a> <a href='javascript:SureDel(<%=rs("id") %>,subjectname="<%=rs("subjectname")%>")'><font size="2">删除</font></a></div></td>
</tr>
<% rs.movenext
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 size='2'>第</font><font color=red>" + cstr(curpage) + "</font><font size='2'>页/共</font><font color=red>" + cstr(rs.pagecount) + "</font><font size='2'>页</font> "
response.write "<font size='2'>本页</font><font color=red>" + cstr(i-1) + "</font><font size='2'>条/共</font><font color=red>" + cstr(rs.recordcount) + "</font><font size='2'>条</font> "
if curpage = 1 then
else
response.write "<a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) & "&page=1'><font size='2'>首页</font></a> <a href='mgquestion.asp?type=" & cstr(request("type")) & "&subjectname=" & cstr(request("subjectname"))& "&page=" & cstr(curpage-1) & "'><font size='2'>前页</font></a> "
end if
if curpage = rs.pagecount then
else
response.write "<a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) & "&page=" + cstr(curpage+1) + "'><font size='2'>后页</font></a> <a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) + "&page=" + cstr(rs.pagecount) + "'><font size='2'>末页</font></a>"
end if
end If
end if
'rs.close
set rs=nothing
%>
<hr size=0 width=100%>
<% 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=2>带*各项均必须完全填写</font></p>
<p align="left"><font color=red size="2">*</font></font size="2"> 问题:</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 size="2">*</font></font size="2"> 科目:</font>
<input type="text" name="subjectname" class=input maxlength=30 size="10" value='<%=subjectname%>'>
</p>
<p align="left">
<font size="2">选项A:</font>
<input type="text" name="A" class=input maxlength=100 size="50" value='<% if isedit then
response.write trim(rs("A"))
end if %>'>
<font color="#FF0000" size="2">* 填空题此选项填写此填空题的总填空数,其他选项不填</font> <br>
<font size="2">选项B:</font>
<input type="text" name="B" class=input maxlength=100 size="50" value='<% if isedit then
response.write trim(rs("B"))
end if %>'>
<br>
<font size="2">选项C:</font>
<input type="text" name="C" class=input maxlength=100 size="50" value='<% if isedit then
response.write trim(rs("C"))
end if %>'>
<br>
<font size="2">选项D:</font>
<input type="text" name="D" class=input maxlength=100 size="50" value='<% if isedit then
response.write trim(rs("D"))
end if %>'>
</p>
<p align="left"><font color=red>*</font><font size="2">答案(请填写选项的字母):</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><font size="2">类型(单选题、多选题、判断题、填空题):</font><input type="radio" name="leixing" value="单选题"
<% if isedit then
if rs("type")="单选题" then
response.write "checked"
end if
end if %>><font size="2">单选题</font>       
<input type="radio" name="leixing" value="多选题"
<% if isedit then
if rs("type")="多选题" then
response.write "checked"
end if
end if
%>><font size="2">多选题</font>       
<input type="radio" name="leixing" value="判断题"
<% if isedit then
if rs("type")="判断题" then
response.write "checked"
end if
end if
%>><font size="2">判断题</font>       
<input type="radio" name="leixing" value="填空题"
<% if isedit then
if rs("type")="填空题" then
response.write "checked"
end if
end if
%>><font size="2">填空题</font></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 + -