Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 21st, 2004, 06:13 PM
Authorized User
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to add a "new topic" in a discussion group

Hi guys,

I am customizing a community discussion group similar to the one we are using. I want to add a "next topic" link and "last topic" link so that users could move to the last or next topic in the same forum(such as ASP Web How to)without going back to the topic listin page first.

Please give me some idea on how to achieve this. I know I could use a code like this to get the current topic:
<a href="forums.asp?ForumId=<% =ForumId %>&TopicId=<% =TopicId %>"><% =Subject %></a>

However, the next TopicId within the same forum is not necessarily TopicId+1, since the next TopicId can be created in another forum. Also Topics can be deleted.

Any idea would be great appreciated!


Old September 21st, 2004, 11:05 PM
Friend of Wrox
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp

You can put all the topics in same table. That table should have an identity column which you can make its primary key also. Then whenever a new topic is added, it will get incremented automatically.

The other method is to create a GUID whenever a new topic needs to be added. You can use a component for creating a GUID. You may also create it by appending current date, time including microsecond and then a 5 digit random number to it. Then you can use that number as the primary key of the topics table. This method is preferable as you can pass this number as querystring without losing security. Whereas if you pass identity defined topic ids through querystring, people may tend to change them in the addressbar and access topics that are not meant for them.

For e.g. if there is a page

http://www.yoursite.com/showtopic.asp?id=33 to display all postings related to a topic, people may change the number 33 to 32 or 31 to access other topics.
Old September 22nd, 2004, 03:07 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

Hi Cinderella,

If I understand that right, you should pass the same ForumId and same TopicId for the NEXT TOPIC link, so that when you query the database you got to find the next topic of same forum by looking for the row that belongs to same forumId but next to the current TopicId that came along with the querystring.

Current TopicId=33
Current ForumId=1

"Next Topic" link should be passed on with same values. So that at the backend, you query for something like...
Select Top 1 TopicId, ForumId, Subject from TableName where ForumId = 1 and TopicId > 33

This gets you the NEXT TopicId of same forum. Similarly, you got to query for Previous, with little change in the ORDER BY clause.
Select Top 1 TopicId, ForumId, Subject from TableName where ForumId = 1 and TopicId < 33 ORDER BY TopicId desc

Hope this is what you are looking for.

- Vijay G
Strive for Perfection

Similar Threads
Thread Thread Starter Forum Replies Last Post
Discussion Group/Forum kkerr Access 5 March 26th, 2007 01:43 PM
Add user to group - Active Directory anurag_ur ASP.NET 2.0 Professional 0 January 17th, 2006 02:54 AM
Add User to group - Active Directory anurag_ur ASP.NET 1.0 and 1.1 Basics 0 January 16th, 2006 09:13 AM
Error when attempting to add New Topic rudydotnet Classic ASP Databases 1 August 22nd, 2005 01:55 PM
ASP Discussion group kosla78 Classic ASP Basics 0 July 3rd, 2003 08:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.