It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Prayer Of Forgiveness
"I forgive all living beings. May all living beings forgive me! I cherish the friendliness towards all and harbour enmity towards none." -- Aavashyaka Sutra(Translated)
Okay, I'll be the sucker that asks the obvious dumb question.
Why? (Just curious...)
Following statements occur twice in topic.asp Lines 469-473 and Lines 714-718
if strShowTopicNav = "1" then
Call Topic_nav()
else
Response.Write("Topic")
end if
The sub Topic_nav() is called twice. Since the variables nextTopic and prevTopic are local to sub they do not hold the information obtained from the db between the two calls to the sub. so they are = "" each time a call is made to the sub. Declaring variables at script level will keep the variables populated with the info obtained from the DB first time.
Sub Topic_nav()
if prevTopic = "" then
strSQL = "SELECT T_SUBJECT, TOPIC_ID "
strSql = strSql & "FROM " & strActivePrefix & "TOPICS "
strSql = strSql & "WHERE T_LAST_POST > '" & Topic_LastPost
strSql = strSql & "' AND FORUM_ID = " & Forum_ID
strSql = strSql & " AND T_STATUS < 2" ' Ignore unapproved/held posts
strSql = strSql & " ORDER BY T_LAST_POST;"
set rsPrevTopic = my_conn.Execute(TopSQL(strSql,1))
if rsPrevTopic.EOF then
prevTopic = getCurrentIcon(strIconBlank,"","align=""top"" hspace=""6""")
else
prevTopic = "<a href=""topic.asp?" & ArchiveLink & "TOPIC_ID=" & _
rsPrevTopic("TOPIC_ID") & """>" & _
getCurrentIcon(strIconGoLeft,"Previous Topic","align=""top"" hspace=""6""") & "</a>"
end if
rsPrevTopic.close
set rsPrevTopic = nothing
else
prevTopic = prevTopic
end if
if NextTopic = "" then strSQL = "SELECT T_SUBJECT, TOPIC_ID "
strSql = strSql & "FROM " & strActivePrefix & "TOPICS "
strSql = strSql & "WHERE T_LAST_POST < '" & Topic_LastPost
strSql = strSql & "' AND FORUM_ID = " & Forum_ID
strSql = strSql & " AND T_STATUS < 2" ' Ignore unapproved/held posts
strSql = strSql & " ORDER BY T_LAST_POST DESC;"
set rsNextTopic = my_conn.Execute(TopSQL(strSql,1))
if rsNextTopic.EOF then
nextTopic = getCurrentIcon(strIconBlank,"","align=""top"" hspace=""6""")
else
nextTopic = "<a href=""topic.asp?" & ArchiveLink & "TOPIC_ID=" & _
rsNextTopic("TOPIC_ID") & """>" & _
getCurrentIcon(strIconGoRight,"Next Topic","align=""top"" hspace=""6""") & "</a>"
end if
rsNextTopic.close
set rsNextTopic = nothing
else
nextTopic = nextTopic
end if
Response.Write (" " & prevTopic & "<b><font face=""" & _
strDefaultFontFace & """ size=""" & _
strDefaultFontSize & """ color=""" & _
strHeadFontColor & """> Topic </font></b>" & nextTopic)
end sub
Edited by - GauravBhabu on 01 October 2002 22:51:04