CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Paged Record Output
When you begin dealing with larger databases it becomes essential to offer the ability to view a few of the database observations at a time rather than dumping the whole db out to the browser. The following script will display the 50 United States, but limit each page to display no more than four states at a time. A total of thirteen pages can by dynamically created from dropdown menu input or buttons leading to the previous or next page. This script is easily adaptable into a db search tool.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<% ' Grabs the contstant for cursorlocation %>
<!--#include file="adovbs.inc" -->
<% 
p=request.form("p")
' Check the value of p (page) and make sure it is not null
' If a null value is found then 1 is put in its place
if p = "" then 
p=1
end if

accessdb="state_info" 
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select statename from states " 

' *********************************** 
' Implements the value from adovbs.inc
rs.cursorlocation=aduseclient
' *************************************
rs.cachesize=5
rs.open sql,cn
rs.movefirst

' Sets the number of observations per page to a max of four
rs.pagesize=4

maxcount=cint(rs.pagecount)

rs.absolutepage=p

%>

<table border="0">
<tr><td valign=top><b>State</b></td></tr>
<%do while not rs.eof and numofobs<rs.pagesize%>
<tr><td valign=top><%=rs("statename")%></td></tr>
<%
rs.movenext
' Counts the number of observations in the current page
numofobs=numofobs+1
loop
%>

</table>


<form method='post' action='<%= request.servervariables("script_name")%>'>
<select name='p' size='1'>

<%
' Starts loop from one to the maximum number of pages 
for counter=1 to cint(rs.pagecount)
%> 

<option<%
' This will select the current page in the dropdown menu
if cint(p) = cint(counter) then 
response.write " selected "
end if
%>
value="<%= counter %>">Page <%= counter %> of <%= cint(rs.pagecount) %></option>
<% next %>
</select>
&nbsp;
<input type="submit" value="Go"</p>
</form>
<br>
<%
if p <> 1 then
%>

<form method='post' action='<%= request.servervariables("script_name")%>'>
<input type = "hidden" name="p" value="<%= p-1 %>">
<input type = "submit" value="&lt;">&nbsp;Previous Page
</form>
<% end if %>
<%
if cint(p) < cint(rs.pagecount) then
%>

<form method='post' action='<%= request.servervariables("script_name")%>'>
<input type = "hidden" name="p" value="<%= p+1 %>">
Next Page&nbsp;<input type = "submit" value="&gt;">
<% end if %>
<p>
<%= numofobs &" states on displayed this page<br>" %>
</p>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3