| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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(" </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 |
|
#2
|
||||
|
||||
|
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! |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Creating HTML - procedure within procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|