conn.asp
-------------------------
<%
'连接数据库开始
dim conn,rs,sql
on error resume next
dbpath=server.mappath("inc/data.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="&dbpath
'创建记录对象
%>
-----------------------------
funtion.asp
---------------------
<%Function cutPage(sqlStr,Conn,dateNums,pageNums,URLs)'利用ADO分页的函数
Dim sql,Cn,dateNum,pageNum,URL,rsDate
Sql=Trim(sqlStr) '获得sql语句。
Set Cn=Conn '获得数据对象
dateNum=Cint(dateNums) '获得每页得记录数
pageNum=Cint(pageNums) '获得当前页码
URL=Trim(URLs) '获得路径
Set rsDate=Server.CreateObject("ADODB.Recordset")
rsDate.PageSize=dateNum
rsDate.Open Sql,cn,1,1
IF rsDate.Eof Then
Response.Write("<center><font stlye='font-size:14px;' color='#ff0000'>对不起,没有记录!</font></center>")
Else
IF pageNum="" or pageNum<1 Then
pageNum=1
ElseIf pageNum>rsDate.PageCount Then
pageNum=rsDate.PageCount
End IF
rsDate.absolutepage =pageNum
Dim recordHead,recordLast '定义当前页开头记录和结束记录
recordHead=1
If pageNum>1 Then recordHead=dateNum*(pageNum-1)
If pageNum>=rsDate.PageCount Then
recordLast=rsDate.RecordCount
Else
recordLast=dateNum*pageNum
End If
Response.Write("<table width=100% border='0' cellpadding='0' cellspacing='0' style='font-size:12px;'>")
Dim URLa '定义判断输入得URL包含?没有的变量
Dim upPage,downPage,allPage '定义向上和向下翻的变量
Dim allWrite '定义输出
upPage=pageNum-1
downPage=pageNum+1
URLa=Split(URL,"?",-1,1)
If URLa(0)=URL Then
upPage="<a href=" & URL & "?page=" & upPage &" stlye='font-size:12px;'>上一页</a> "
If pageNum=1 Then upPage=""
downPage="<a href=" & URL & "?page=" & downPage &" stlye='font-size:12px;'>下一页</a>"
If pageNum=rsDate.PageCount Then downPage=""
Else
upPage="<a href=" & URL & "&page=" & upPage &" stlye='font-size:12px;'>上一页</a> "
If pageNum=1 Then upPage=""
downPage="<a href=" & URL & "&page=" & downPage &" stlye='font-size:12px;'>下一页</a>"
If pageNum=rsDate.PageCount Then downPage=""
End If
allWrite=upPage & downPage & "
共" & rsDate.PageCount & "页 " & "目前第"& pageNum &"页"
allwrite="<font style='font-size:12px;'>" & allWrite & " 到第<input type='text' style='width:30px;' Name='page' value="& pageNum &">页<input type='submit' value='GO'></font>"
Response.Write("<tr><form name='formPage' method='post' action="&URL&"><td colspan='2' align=right style='font-szie=12px;'>" & allWrite & "</td></form></tr>")
Response.Write("<tr><td colspan='2' align=center>")
Response.Write("<table width=100% border='0' cellpadding='0' cellspacing='0' style='font-size:12px;'>")
Response.Write("<tr bgcolor='#ffdf99' height=25>")
Dim id,i
For i=0 to rsDate.Fields.Count-1 '设置表头
Response.Write("<td align='center'><font style='font-size:13px;'><b>"&rsDate.Fields(i).Name&"</b></font></td>")
Next
Response.Write("</tr>")
id=0
While not rsDate.EOF and id<dateNum
id=id+1
If id Mod 2=0 then
Response.Write("<tr bgcolor=#f7f6e7>")
Else
Response.Write("<tr bgcolor=#ffffff>")
End If
For Each fils in rsDate.Fields
Response.Write("<td align='center' height=20>"&fils&"</td>")
Next
Response.Write("</tr>")
rsDate.MoveNext
Wend
Response.Write("<tr height=25 bgcolor='#ffdf99'>")
For i=0 to rsDate.Fields.Count-1 '设置表尾
Response.Write("<td align='center'><font style='font-size:13px;'><b>"&rsDate.Fields(i).Name&"</b></font></td>")
Next
Response.Write("</tr>")
Response.Write("</table></td></tr>")
Response.Write("<tr><td height=30 align=left><font stly='font-size:12px;'>(第"&recordHead&"-"&recordLast&"条,共"&rsDate.Recordcount&"条,每页显示"&dateNum&"条)</font></td>")
Response.Write("<form name='formPage1' method='post' action="&URL&"><td height=30 align=right>" & allWrite & "</td></form></tr></table>")
End IF
rsDate.close
Set rsDate=nothing
End Function
%>
---------------------
yp.asp
--------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<%
province=request("mainmenu")
city=request("submenu")
leibie=request("leibie")
schoolname=request("schoolname")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>教育黄页</title>
<style type="text/css">
<!--
body {
background-image: url();
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
font-size: 12px;
}
.STYLE1 {font-size: 12px}
.STYLE3 {color: #003366}
.STYLE6 {color: #993300}
tr {
background-repeat: repeat-x;
}
.STYLE7 {color: #FFFFFF}
.STYLE8 {color: #FF0000}
-->
</style>
</head>
<body>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <table width="77%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="689"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/top1.jpg" width="187" height="78" /><img src="images/top2.jpg" width="500" height="78" /></td>
</tr>
</table></td>
<td width="99"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><img src="images/23.gif" width="16" height="16" /></div></td>
<td>设为首页</td>
</tr>
<tr>
<td><div align="center"><img src="images/18.gif" width="16" height="16" /></div></td>
<td>加入收藏</td>
</tr>
</table></td>
</tr>
<tr>
<td height="30" colspan="2" background="images/line.gif">&nbsp;&nbsp;<span class="STYLE7">首页</span> | <span class="STYLE7">教育新闻</span> | <span class="STYLE7">益学网视</span> | <span class="STYLE7">益学网赛</span> | <span class="STYLE7">校园网刊</span> | <span class="STYLE7">奖励中心</span> | <span class="STYLE7">帐号管理</span> | <span class="STYLE8">教育黄页</span> | <span class="STYLE7">教育公社</span> | <span class="STYLE7">益智游戏</span> </td>
</tr>
<tr>
<td height="102" colspan="2"><table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="187" height="102" align="right" valign="top" background="images/tu1.gif"><br />
<span class="STYLE3">地区搜索:</span><br /></td>
<td width="500" valign="top" background="images/tu2.gif"><br />
<br />
<span class="STYLE6">北京 上海 江苏 浙江 广东 河北 河南 湖北 安徽 湖南 香港 天津 四川 重庆 吉林 辽宁 <br />
<br />
青海
宁夏 新疆 云南 广西 内蒙古 海南 江西 福建 贵州 西藏 山东 甘肃 山西 陕西 台湾 <br />
<br />
黑龙江 </span></td>
<td width="81" valign="top" background="images/tu3.gif"><br />
<br /></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" background="images/dot_line.gif"><img name="" src="" width="32" height="1" alt="" /></td>
</tr>
<tr>
<td height="23" colspan="2" background="images/line2.gif">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr >
<!--#include file="search.asp"-->
</tr>
</table>
</td>
</tr>
<tr> <td colspan='2'>
<table width=100% height=28 border='0' cellpadding='0' cellspacing='0'>
<tr><td width='15' ><img src='images/arrow.gif' width='11' height='14'/></td>
<td>首页
<% set rs5=server.CreateObject("adodb.recordset")
sql5="select * from areamain where province_ID="&province
rs5.open sql5,conn,1,1
set rs6=server.CreateObject("adodb.recordset")
sql6="select * from areasub where city_ID="&city
rs6.open sql6,conn,1,1
set rs7=server.CreateObject("adodb.recordset")
sql7="select * from leibie where leibie_ID="&leibie
rs7.open sql7,conn,1,1
%>
<% if (not isempty(province)) then %>
<span class='STYLE1'>&gt;&gt;&gt; <%=rs5("name")%></span>
<%end if%>
<% if (not isempty(city)) then%>
<span class='STYLE1'>&gt;&gt;&gt; <%=rs6("name")%></span>
<%end if%>
<%if (not isempty(leibie)) then%>
<span class='STYLE1'>&gt;&gt;&gt; <%=rs7("name")%></span>
<% end if%>
<span class='STYLE1'>&gt;&gt;&gt; <%=schoolname%></span>
</td></tr></table></td></tr>
<tr>
<td colspan="2">
<%
if not isempty(province) and not isempty(city) and isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"order by 编号 asc "
end if
if not isempty(province) and not isempty(city) and not isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"and leibie_ID="&leibie &"order by 编号 asc "
end if
if not isempty(province) and not isempty(city) and not isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"and leibie_ID="&leibie &"and 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
if isempty(province) and isempty(city) and not isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where leibie_ID="&leibie &"and 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
if isempty(province) and isempty(city) and isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
if isempty(province) and isempty(city) and isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school order by 编号 asc "
end if
if isempty(province) and isempty(city) and not isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where leibie_ID="&leibie &"order by 编号 asc "
end if
if not isempty(province) and not isempty(city) and isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"and 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
%>
<%
page=request("page")
url="yp.asp"
call cutPage(sql,conn,"19",page,url)
%>
<!--#include file="function.asp"-->
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>