Hey all. I've been making my own forum application and I was thinking, "How do I make it so that new replies/ new topics will show up at the top of the page?"
Right now, I'm sorting the data by;
Sticky - Separate selection than the regular datas. So example would be for stickies I'd do
SELECT id, title, timestamp FROM topics WHERE category = ? ORDER BY id AND sticky DESC
Then for a regular topic that isn't sticky, I'd do
SELECT id, title, timestamp FROM topics WHERE category = ? AND sticky = ? ORDER BY id DESC
This one is a little similar, but not completely. sticky = ? is specified to 0 which means that the topic is not sticky and is a regular topic. So when ever someone posts a topic the sticky topics will always stay at the top while the regular topics are under the sticky topics.
Example:
Ebola outbreak - (35 posts) - Sticky
Cancer awareness month - (9 posts) - Sticky
-----------
Have you heard of this new disease yet? - (1 post) - regular topic
I just ate something poisonous - (0 posts) - regular topic
After a few hours
[CODE]
Ebola outbreak - (35 posts) - Sticky
Cancer awareness month - (9 posts) - Sticky
I thought this was fake - (0 posts) - regular topic
Nothing is done with these diseases - (12 posts) - regular topic
Have you heard of this new disease yet? - (5 post) - regular topic
Growing fungous - (0 posts) - regular topic
I just ate something poisonous - (0 posts) - regular topic[/CODE]
So basically the logic to this forum is to bump what ever is new or what ever gets replied to the top of the page while old topics get pushed down. The sticky topics aren't affected at all because the sticky topics has a separate SELECT to it.
How would I go about this? I don't want to post my codes because it's 2000 + lines of code. Just want to get some insight or reviews on how I should do this.