Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 13th, 2004, 06:40 PM
kishorebudha kishorebudha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 3 kishorebudha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Creating HTML - procedure within procedure

I am planning to produce an academic journal and prefer flat HTML files as I have issues with hosting and database. I have written an ASP code that generates flat html files using text from a DB

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "tmw"
set rs=Server.CreateObject("ADODB.recordset")
sql= "SELECT * FROM tblContent WHERE Topstory='Yes' AND Status='Current'"
rs.Open sql, conn
%>

<%rs.MoveFirst
do while not rs.eof
' Creates a text file on the server with the content ID
' as the name for the ouput document
filename= rs("ID") & "_" & "topstory" & month(date) & "_" & year(date) & ".html"
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath(filename), true)
set fso = nothing 'Clean up!

'A TABLE WITH TWO COLUMNS. FIRST COLUMN DISPLAYS THE RECORD. THE SECOND COLUMN TO DISPLAY ALL THE HEADLINES IN THE RECORDSET
'SOME HTML IS GENERATED USING FIELDS FROM THE TABLE - Section, Headline, Author, Blurb, Full Text
act.WriteLine("<table border='0' cellpadding='10' cellspacing='0' width='760'>")
act.WriteLine("<tr>")
act.WriteLine("<td width='100%'>")
act.WriteLine("<table border='0' cellpadding='10' cellspacing='0' width='100%'>")
act.WriteLine("<tr>")
act.WriteLine("<td width='100%'>")
act.writeline("<p class='menuname'>~ " & rs("Section") & "</p>")
act.WriteLine("<p class='menuhead1'>" & rs("Headline") & "</p>" )
act.WriteLine("<p class='byline'>" & rs("Author") & "<p></p>" )
act.WriteLine("<p class='articleintro'>" & rs("Blurb") & "<p></p>")
act.WriteLine("<p class='articlebody'>" & rs("Fulltext") & "<p></p>")
act.WriteLine("</td>")
act.WriteLine("</tr>")
act.WriteLine("</table>")
act.WriteLine(" </td>")
act.WriteLine(" </tr>")

act.WriteLine("<tr>")
act.WriteLine("<td width='100%'>")
act.WriteLine(" </td>")
act.WriteLine(" </tr>")
act.WriteLine(" </table>")


act.close
rs.movenext
loop
%>

I want the headlines and links to headlines from the section to appear on all the pages being created by this application. How do I get it to work. The code for it is:

rs.MoveFirst
do while not rs.eof
act.WriteLine("<p class='rightmenuheadlines'>" & "<a href='" & rs("ID") & "_" & "topstory" & month(date) & "_" & year(date) & ".html'>" & rs("Headline") & "</a>" & "</p>" )
rs.movenext
loop

Reply With Quote
  #2  
Old September 20th, 2004, 05:53 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Why don't you produce a simpler system by writing a seperate HTML file and reading it with the FSO. You can then loop through RecordSet.Fields() and populate tags in your HTML file (e.g. #Tag1#). Once you have substituted all of the values, you can write it to the new HTML file using the FSO
__________________
selwonk

If I've posted some code above, you might think it looks a bit simplistic. It might be. I'd rather people tried the next step themselves rather than getting a full solution on a plate. That way they learn more!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Creating HTML - procedure within procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT