Forums
This topic is locked
DB to static (HTML) page
Posted 25 Apr 2007 15:19:57
1
has voted
25 Apr 2007 15:19:57 Dimitris Kouris posted:
Hi all,
Is there any way of creating HTML pages based on the content of the db?
For example, lets say i have a list of 500 products stored in my db, how can I make these products appear on an html page? Also, (preferably) I would like to store each generated html page in its own folder which ideally would be created only once. I addition, and I need to be able to update / over-write the html page to match the content of the db when the db is updated.
To sum-up:
1) db content to html page
2) each html page should have it own folder (dir)
3) ability to update/overwrite the old html page when the db is updated
Is it possible?
Thanks in advance!
Dimitris
Replies
Replied 16 May 2007 23:06:54
16 May 2007 23:06:54 dave blohm replied:
This is a fairly simple example of how to work with files and folder dynamically using the File Scripting Object but should give you a pretty good starting point for you to do what you are looking to do. Let me know if you have questions.
<pre id=code><font face=courier size=2 id=code><%
' ::::: THIS IS WHERE I WOULD OPEN A RECORDSET THAT CONTAINS
' ::::: THE INFO I WANT IN YOUR HTML FILE AND I WOULD WRITE
' ::::: HTML THAT I WANT ON MY PAGE IN THE FSO.WRITELINE"
' ::::: BELOW
' ::::: THIS EXAMPLE CREATES TEN DIRECTORIES EACH WITH ONE HTML
' ::::: FILE IN IT
for i = 1 to 10
Set fs_folder=Server.CreateObject("Scripting.FileSystemObject"
Set fso_folder = fs_folder.CreateFolder(server.mappath("./" & i))
set fs_file=Server.CreateObject("Scripting.FileSystemObject"
set fso_file=fs_file.CreateTextFile(server.mappath("./" & i & "/html_file_" & i & ".htm")
fso_file.WriteLine("Dynamic text - " & i)
fso_file.close
set fso_file=nothing
set fs_file=nothing
set fo_folder=nothing
set fs_folder=nothing
next
%></font id=code></pre id=code>
Hope this helps.
- Doc
Progress is made by the discontent.
Edited by - daveblohm on 16 May 2007 23:08:33
Edited by - daveblohm on 16 May 2007 23:09:02
<pre id=code><font face=courier size=2 id=code><%
' ::::: THIS IS WHERE I WOULD OPEN A RECORDSET THAT CONTAINS
' ::::: THE INFO I WANT IN YOUR HTML FILE AND I WOULD WRITE
' ::::: HTML THAT I WANT ON MY PAGE IN THE FSO.WRITELINE"
' ::::: BELOW
' ::::: THIS EXAMPLE CREATES TEN DIRECTORIES EACH WITH ONE HTML
' ::::: FILE IN IT
for i = 1 to 10
Set fs_folder=Server.CreateObject("Scripting.FileSystemObject"
Set fso_folder = fs_folder.CreateFolder(server.mappath("./" & i))
set fs_file=Server.CreateObject("Scripting.FileSystemObject"
set fso_file=fs_file.CreateTextFile(server.mappath("./" & i & "/html_file_" & i & ".htm")
fso_file.WriteLine("Dynamic text - " & i)
fso_file.close
set fso_file=nothing
set fs_file=nothing
set fo_folder=nothing
set fs_folder=nothing
next
%></font id=code></pre id=code>
Hope this helps.
- Doc
Progress is made by the discontent.
Edited by - daveblohm on 16 May 2007 23:08:33
Edited by - daveblohm on 16 May 2007 23:09:02