Forum Overview :: Site Comments
 
Re: Need my \'Previous\' and \'Next\' links by E. L. Koba 12/24/2002, 9:27pm PST
Entropy Stew wrote:


This requires seriously rewriting the way I write out threads (boring: it currently uses a recursive function that writes everything out as walks the thread tree, and therefore qould bepain my ass to get the next post id), so I'm not pegging it as high priority at the moment. I'll get it in eventually, though.


But but but you print them in order so ...
Wherever you have a print now, store what you got until the next go-through of the loop and then fill in the "next post" id and print. Special-case the last line so that gets printed after the loop exits.

The general idea is to print the data from the cell previous to whichever one you're inside of, at which time you know both previous- and next-post id's.

(props to awk)

Ray!


How would I go about writing a next and previous button at the top of the screen when I'm already printing out the thread at the bottom? By paining my ass, is how - I'd have to restructure the program flow(proper way which requires thinking) OR add another DB query at the top, along with the requisite thread-crunching code(fast to write, but slows the script down, is both ugly and redundant, would cause me to go into dry heaves after I went back and read the atrocity penned by mine own editor, etc.). In other word, I'm pushing this back into the queue because the payback isn't worth the effort that could be spent fixing bugs.

-/ES/-


Just write all the thread info into an array with your recursive function before you start writing out the page. Then it's a simple matter to see what is the previous and next posts just by looking at the element before and after the current post in the array.

It's usually better to seperate the db code and the display code anyway.

Work harder! This moving the mouse around so much is driving me to distraction.
PREVIOUS REPLY QUOTE
 
Need my \'Previous\' and \'Next\' links by El Koba 12/20/2002, 9:15pm PST NEW
    Re: Need my \'Previous\' and \'Next\' links by Entropy Stew 12/21/2002, 3:11am PST NEW
        Re: Need my \'Previous\' and \'Next\' links by Ray, of Light 12/22/2002, 11:07pm PST NEW
            Re: Need my \'Previous\' and \'Next\' links by Entropy Stew 12/24/2002, 3:16pm PST NEW
                Re: Need my \'Previous\' and \'Next\' links by E. L. Koba 12/24/2002, 9:27pm PST NEW
 
powered by pointy