📄 index.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% 'no security checking %>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>
<!--#include file="db.asp"-->
<%
displayRecs = 30
recRange = 10
%>
<%
' Get table name
tablename = "[dictionary]"
dbwhere = ""
a_search = ""
b_search = ""
c_search = ""
%>
<%
' Get search criteria for basic search
pSearch = Request.QueryString("psearch")
If pSearch <> "" Then
pSearch = replace(pSearch,"'","''")
pSearch = replace(pSearch,"[","[[]")
b_search = b_search & "[EnglishWord] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Chinese] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[yin] LIKE '%" & pSearch & "%' OR "
End If
If len(b_search) > 4 Then
b_search = mid(b_search,1,len(b_search)-4)
b_search = "(" & b_search & ")"
End If
%>
<%
'Build search criteria
If a_search <> "" Then
dbwhere = dbwhere & a_search 'advance search
ElseIf b_search <> "" Then
dbwhere = dbwhere & b_search 'basic search
End If
'Save search criteria
If dbwhere <> "" Then
Session("tablename") = tablename
Session("dbwhere") = dbwhere
'reset start record counter
startRec = 1
Session("dictionary_REC") = startRec
Else
If tablename = Session("tablename") Then
dbwhere = Session("dbwhere")
Else
'reset search criteria
dbwhere = ""
Session("dbwhere") = dbwhere
End If
End If
'Get clear search cmd
If Request.QueryString("cmd").Count > 0 then
cmd=Request.QueryString("cmd")
If ucase(cmd) = "RESET" Then
'reset search criteria
dbwhere = ""
Session("dbwhere") = dbwhere
End If
End If
%>
<%
' Load Default Order
DefaultOrder = "EnglishWord"
DefaultOrderType = "ASC"
' Check for an Order parameter
OrderBy = ""
If Request.QueryString("order").Count > 0 Then
OrderBy = Request.QueryString("order")
' Check if an ASC/DESC toggle is required
If Session("dictionary_OB") = OrderBy Then
If Session("dictionary_OT") = "ASC" Then
Session("dictionary_OT") = "DESC"
Else
Session("dictionary_OT") = "ASC"
End if
Else
Session("dictionary_OT") = "ASC"
End If
Session("dictionary_OB") = OrderBy
Session("dictionary_REC") = 1
Else
OrderBy = Session("dictionary_OB")
if OrderBy = "" then
OrderBy = DefaultOrder
Session("dictionary_OB") = OrderBy
Session("dictionary_OT") = DefaultOrderType
End If
End If
' Check for a START parameter
If Request.QueryString("start").Count > 0 Then
startRec = Request.QueryString("start")
Session("dictionary_REC") = startRec
Else
startRec = Session("dictionary_REC")
if not isnumeric(startRec) or startRec = "" then
'reset start record counter
startRec = 1
Session("dictionary_REC") = startRec
End If
End If
' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
' Build Query
strsql = "select top 8 * from [dictionary]"
If dbwhere <> "" Then
strsql = strsql & " WHERE " & dbwhere
End If
if OrderBy <> "" then
strsql = strsql & " ORDER BY [" & OrderBy & "] " & Session("dictionary_OT")
end if
'response.write strsql
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
totalRecs = rs.RecordCount
%>
<!--#include file="header.asp"-->
<form action="index.asp"><div align="center">
<center>
<table border="0" cellspacing="0" cellpadding="4" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td><font size="3">快速查询</font></td>
<td>
<input type="Text" name="psearch" size=16>
<input type="Submit" name="Submit" value="开始搜索">
</td>
<td></td>
</tr>
</table>
</center>
</div>
</form>
<form>
<table align="center" border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC" width="67%" height="2">
<tr bgcolor="#0099CC">
<td width="22%" align="center" bgcolor="#336699" height="18">
<a href="index.asp?order=<%= Server.URLEncode("EnglishWord") %>" style="font-size: xx-small">
<font color="#FFFFFF">English Word</font></a></td>
<td width="22%" align="center" bgcolor="#336699" height="18">
<a href="index.asp?order=<%= Server.URLEncode("yin") %>" style="font-size: xx-small">
<font color="#FFFFFF">音标</font></a></td>
<td width="56%" align="center" bgcolor="#336699" height="18">
<a href="index.asp?order=<%= Server.URLEncode("Chinese") %>" style="font-size: xx-small">
<font color="#FFFFFF">中文意思</font></a></td>
</tr>
<%
'Avoid starting record > total records
if clng(startRec) > clng(totalRecs) then
startRec = totalRecs
end if
'Set the last record to display
stopRec = startRec + displayRecs - 1
'Move to first record directly for performance reason
recCount = startRec - 1
if not rs.eof then
rs.movefirst
rs.move startRec - 1
end if
recActual = 0
Do While (NOT rs.EOF) AND (recCount < stopRec)
recCount = recCount + 1
If Clng(recCount) >= Clng(startRec) Then
recActual = recActual + 1 %>
<%
'set row color
bgcolor="#FFFFFF"
%>
<%
' Display alternate color for rows
If recCount mod 2 <> 0 Then
bgcolor="#F5F5F5"
End If
%>
<%
x_ID = rs("ID")
x_EnglishWord = rs("EnglishWord")
x_Chinese= rs("Chinese")
x_yin= rs("yin")
%>
<tr bgcolor="<%= bgcolor %>">
<td width="22%" align="center" height="-1"><font size=" x-small" face=宋体>
<% response.write x_EnglishWord %>
</font></td>
<td width="22%" align="center" height="-1"> <font size=" x-small" face=Vrinda>
<font face="Kingsoft Phonetic Plain">
<% response.write x_yin %></font>
</font></td>
<td width="56%" align="center" height="-1"><font size=" x-small" face=Vrinda>
<% response.write x_Chinese %></font><font color="#CCCCCC"><% else %></font> </td>
</tr>
<%
end if
rs.MoveNext
Loop
%>
</table>
</form>
<font color="#CCCCCC">
<center>
<%
if totalRecs > 0 then
' Find out if there should be Backward or Forward Buttons on the table.
If startRec = 1 Then
isPrev = False
Else
isPrev = True
PrevStart = startRec - displayRecs
If PrevStart < 1 Then PrevStart = 1 %>
<strong><a href="index.asp?start=<%=PrevStart%>" class="boldlink1">
<font size="-1" color="#CCCCCC">[<< Prev]</font></a></strong><font color="#CCCCCC">
<%
End If
' Display Page numbers
If (isPrev OR (NOT rs.EOF)) Then
If (NOT isPrev) Then Response.Write ""
x = 1
y = 1
dx1 = ((startRec-1)\(displayRecs*recRange))*displayRecs*recRange+1
dy1 = ((startRec-1)\(displayRecs*recRange))*recRange+1
If (dx1+displayRecs*recRange-1) > totalRecs then
dx2 = (totalRecs\displayRecs)*displayRecs+1
dy2 = (totalRecs\displayRecs)+1
Else
dx2 = dx1+displayRecs*recRange-1
dy2 = dy1+recRange-1
End If
While x <= totalrecs
If x >= dx1 and x <= dx2 Then
If Clng(startRec) = Clng(x) Then %>
<strong><font size="-1"><%=y%></font></strong>
<% Else %> </font>
<strong><a href="index.asp?start=<%=x%>" class="boldlink1">
<font size="-1" color="#CCCCCC"><%=y%></font></A></strong><font color="#CCCCCC">
<% End If
x = x + displayRecs
y = y + 1
elseif x >= (dx1-displayRecs*recRange) and x <= (dx2+displayRecs*recRange) then
if x+recRange*displayRecs < totalRecs then %> </font>
<strong><a href="index.asp?start=<%=x%>" class="boldlink1">
<font size="-1" color="#CCCCCC"><%=y%>-<%=y+recRange-1%></font></a></strong><font color="#CCCCCC">
<% else
ny=(totalRecs-1)\displayRecs+1
if ny = y then %> </font>
<strong><a href="index.asp?start=<%=x%>" class="boldlink1">
<font size="-1" color="#CCCCCC"><%=y%></font></a></strong><font color="#CCCCCC">
</font><strong><a href="index.asp?start=<%=x%>" class="boldlink1">
<font size="-1" color="#CCCCCC"><%=y%>-<%=ny%></font></a></strong><font color="#CCCCCC">
<% end if
end if
x=x+recRange*displayRecs
y=y+recRange
else
x=x+recRange*displayRecs
y=y+recRange
End If
Wend
End If
' Next link
If NOT rs.EOF Then
NextStart = startRec + displayRecs
isMore = True %> </font>
<strong><a href="index.asp?start=<%=NextStart%>" class="boldlink1">
<font size="-1" color="#CCCCCC">[Next >>]</font></a></strong><font color="#CCCCCC">
<% Else
isMore = False
End If %>
<% If stopRec > recCount Then stopRec = recCount %>
<br>
</font>
</font>
<font size="-1">Words<font color="#808080"> <%= startRec %>
</font>to<font color="#808080"> <%= stopRec %> </font>of<font color="#808080"> <%= totalRecs %></font></font><font color="#808080">
<% Else %>
</font><font color="#CCCCCC"><font color="#FFFFFF"><font size="-1">何词!</font> </font>
<br>
</font>
<% End If %><%
' Close recordset and connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing %>
<%Session.CodePage=936%>
<!--#include file="footer.asp"-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -