M
Mike Brind
<Mental block>
I want to display a kind of two-tier one-to-many relationship, for
which, in the olden days, I would have used a series of nested loops
and multiple calls to the db.
Here's the trimmed down code so far:
<%
sql = "SELECT StoryType.StoryType, Articles.ArticleID, Articles.Title,
Authors.Initials, Authors.AuthorName FROM StoryType INNER JOIN (Authors
INNER JOIN (Articles INNER JOIN ArticleAuthors ON Articles.ArticleID =
ArticleAuthors.ArticleID) ON Authors.AuthorID =
ArticleAuthors.AuthorID) ON StoryType.StoryTypeID =
Articles.StoryTypeID"
currentstorytype = ""
currentid = ""
s = ""
set rs = objconnection.execute(sql,,4)
arr = rs.getrows()
rs.close : set rs = nothing
for i = 0 to ubound(arr,2)
if arr(0,i) <> currentstorytype then
s = s & vbcrlf & vbcrlf & "<h5>" & arr(0,i) & "S</h5>" & vbcrlf
currentstorytype = arr(0,i)
end if
if arr(1,i) <> currentid then
s = s & "<p>" & arr(2,i) & "<br />" & vbcrlf
currentid = arr(1,i)
end if
s = s & arr(3,i) & " " & arr(4,i) & ", "
next
response.write s
%>
This displays the db content as follows:
STORYTYPE
Article title
Author 1, Author 2, Author 3,
Article title
Author 1, Author2,
STORYTYPE
Article title
Author 1,
Article Title
Author 1, Author 2, Author 3, Author 4,
This all works fine - except for one thing - I am having a real mental
block when it comes to identifying where the author list for each title
ends, so that I don't display a comma, and can close that section off
with a "</p>".
Suggestions, anyone?
Cheers
I want to display a kind of two-tier one-to-many relationship, for
which, in the olden days, I would have used a series of nested loops
and multiple calls to the db.
Here's the trimmed down code so far:
<%
sql = "SELECT StoryType.StoryType, Articles.ArticleID, Articles.Title,
Authors.Initials, Authors.AuthorName FROM StoryType INNER JOIN (Authors
INNER JOIN (Articles INNER JOIN ArticleAuthors ON Articles.ArticleID =
ArticleAuthors.ArticleID) ON Authors.AuthorID =
ArticleAuthors.AuthorID) ON StoryType.StoryTypeID =
Articles.StoryTypeID"
currentstorytype = ""
currentid = ""
s = ""
set rs = objconnection.execute(sql,,4)
arr = rs.getrows()
rs.close : set rs = nothing
for i = 0 to ubound(arr,2)
if arr(0,i) <> currentstorytype then
s = s & vbcrlf & vbcrlf & "<h5>" & arr(0,i) & "S</h5>" & vbcrlf
currentstorytype = arr(0,i)
end if
if arr(1,i) <> currentid then
s = s & "<p>" & arr(2,i) & "<br />" & vbcrlf
currentid = arr(1,i)
end if
s = s & arr(3,i) & " " & arr(4,i) & ", "
next
response.write s
%>
This displays the db content as follows:
STORYTYPE
Article title
Author 1, Author 2, Author 3,
Article title
Author 1, Author2,
STORYTYPE
Article title
Author 1,
Article Title
Author 1, Author 2, Author 3, Author 4,
This all works fine - except for one thing - I am having a real mental
block when it comes to identifying where the author list for each title
ends, so that I don't display a comma, and can close that section off
with a "</p>".
Suggestions, anyone?
Cheers