<% option explicit
Response.Expires = 0
Dim fs, fd, buffer, rs, arrTxT, Page, i, nPages
'создаемобъект Recordset
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Fields.Append "Страна", 200, 255
rs.Fields.Append "Столица", 200, 255
rs.Open
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set fd = fs.OpenTextFile(Server.MapPath("country.txt"), 1)
'построчно считываем содержимое файла
Do While (Not fd.AtEndOfStream)
'добавляем строку
rs.AddNew
buffer = fd.ReadLine
arrTxT = Split(CStr(buffer), ",")
rs("Страна") = arrTxT(0)
rs("Столица") = arrTxT(1)
rs.Update
Loop
Set fs = Nothing
'сортируем по полю Страна
rs.Sort="Страна"
'по 5 записей на страницу
rs.PageSize = 5
if Request.QueryString("Page") <> "" then
Page = CInt(Request.QueryString("Page"))
else
Page=1
end if
If rs.PageCount > 0 Then
rs.AbsolutePage = Page
Else
Page = 0
End If
Response.Write "<table border = 1 width=200 bordercolor='#000000'>"
Response.Write "<tr><td align=center bgcolor='#EEEEEE'><b>Страна</b></td>"
Response.Write "<td align=center bgcolor='#EEEEEE'><b>Столица</b></td></tr>"
i = 0
'собственновывод
Do While (Not rs.EOF) And (i < rs.PageSize)
Response.Write "<tr>"
Response.Write "<td align=center>" & rs("Страна") & "</td>"
Response.Write "<td align=center>" & rs("Столица") & "</td>"
Response.Write "</tr>"
rs.MoveNext
i = i + 1
Loop
nPages = rs.PageCount
'панель навигации по страницам
If nPages > 1 then
Response.Write "<tr><td colspan=2 align=center>"
If Page <> 1 then
Response.Write "<a href=""" & Request("script_name") & "?Page=" & Page - 1 & """><</a>"
Else
Response.Write "<"
End If
For i = 1 to nPages
If i = 1 then
Response.Write " | "
End If
If i = Page then
Response.Write i & " | "
Else
Response.Write "<a href=""" & Request("script_name") & "?Page=" & i & """>" & i & "</a> | "
End If
Next
If Page <> nPages then
Response.Write "<a href=""" & Request("script_name") & "?Page=" & Page + 1 & """>></a>"
Else
Response.Write ">"
End If
Response.Write "</td></tr>"
End If
Response.Write "</table>"
rs.Close
Set rs = Nothing
%>
|