So I have these tables:
Topics
id, title, date
Posts
id, title, text, date, user, topic_id
How should I structure it so that the first post, the topics text, is on top of all other posts in the topic? Sort them by date? Or is there a smarter way?
mysql_query("SELECT * FROM posts SORT BY date ASC");
Actually now that I look at this you may want to add time and sort by time and date, so that way two posts in the same day are shown in the correct order. It is not very clean to sort by id.
When adding pagination, you will be using MySQL's LIMIT to choose the records for that page. So if you are showing 20 records per page the query would look as so.
1st page:
mysql_query("SELECT * FROM posts SORT BY date ASC LIMIT 0,20");
2nd page:
mysql_query("SELECT * FROM posts SORT BY date ASC LIMIT 20,40");
The first page is calling records 0 through 20. The second page is calling records 20 through 40.
It will sort them by date and time (maybe) accordingly. I am interested in how your forum will turn out! Let us know!
Best of Luck!! Let me know if you have any questions or concerns.