• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing comments - Help needed  RSS feed

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I want to display some text and the database table that I have to store these text is like this, TId is the TextId and RId is the referenceId.

TId RId
1
2 1
3 2
4
5 1

Now, the actual text will come from some other table. I want to display them in my code like this

1
2 (replied for 1)(one indendation in the web page)
3 (replied for 2)(two indendations in the web page)...and goes on
5 (replied for 1)(one indendation in the web page)

How can I acheive this?
[ January 10, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to display something similiar to this

If you go that page scroll to the middle of the page and you will see something that says Threaded replies in a square box and I'm trying to devise a logic similiar to that.

Any idea guys???
[ January 10, 2008: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Mark Newton
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming that you want, from your example:


What about something like:

- Get the first tID.
- Call recursive method printPost(tID)

The method printPost(tID) would then:

- Print the text associated with tID
- Look for any records where rID = this tID
- For each of the above records, print an indent, then get THEIR tID and recursively call printPost(tID) (with the new tID).
- If there aren't any such records, just go on to the next tID.

I guess you'll probably also want to keep track of which tID's you've already printed, as responses to previous tID's, so you don't print each piece of text more than once (unless that's your intention, of course). For example, I guess you don't want:


So you need a record of the fact that you printed 2, 3 and 5 under 1, to avoid printing them again further on.

Sorry - that's probably not particularly clear, but I think it's how I'd approach it...

Cheers,
Dave.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!