- ASP - Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


Create HTML Pages from Access Db by Group
In a previous article Access To HTML we demonstrated how an access db can be utlized to output each observation into a static html page. This demonstration will illustrate how to output html pages from an access db by a category within the db. In our previous example we created 50 pages here the 50 states will be divided into 34 cateogries. After reading the contents of the db instead of writing output to the browser it is written to the server. Each category (Year entered into the Union) will have its own dynamically created page with its corresponding info displayed as well (All the states that entered in that year). A table of contents page is also created (in the browser) for easy navigation around all the state pages. The current time (server time) is also added to show that all the .htm pages are created on the fly. When executing this on your server be certain to have user write authority established on the directory you're executing from.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

Create HTML Pages from Access Db by Group)</title>
<body bgcolor="#FFFFFF">
' Name of the access db being queried

' Connection string to the access db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Query the states table for all state info ordered by year 
' entered and state name
sql = "select year,state,statename,capital,year,order "
sql = sql & "from states order by year, statename " 
rs.Open sql, cn

' Move to the first record

' Loop to output all records
do while not rs.eof

' if variable the_year <> the current record value for year
' create a new html page for db output
if the_year <> clng(rs("year")) then

' Create a hyperlink in the browser output for the current year
response.write "<a href=""" & rs("year") & ".htm"" target=""_blank"">"
response.write rs("year") & "</a> created at" & now() & "<br>"

' Create a file based on the current year record
file_being_created= rs("year") & ".htm"
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)

' Write output to the top of the html document
act.WriteLine("<title>State(s) that entered the Union in " & rs("year") &"</title>")
act.WriteLine("<body bgcolor=""#FFFFFF"">")

end if 'end check for new document

' Write out the observation to the text document
act.WriteLine("State: " & rs("statename") & "<br>" )
act.WriteLine("Abbreviaton: " & rs("state") & "<br>" )
act.WriteLine("Capital: " & rs("capital") & "<br>")
act.WriteLine("Entered the Union in "& rs("year") & "<br>")
act.WriteLine("Number in order of entrance into the Union "& rs("order") &"<br>")

' Place the current record value for year in the variable the_year

' move to the next record

' Check the year value agains the next record
' if they are different close the current document
' and write all the footers. the on error resume next
' prevent an error on the last ineeration of the recordset
on error resume next

if the_year <> clng(rs("year")) then
act.WriteLine("<p>Page created on: " & now ())

' close the text document

end if ' end check for year aganst the rs.year value

' Kill the recordset
set rs=nothing





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 is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

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