I am currently building a blog from scratch for a website I’m building because my client asked me to do so as opposed to using a simple library. Each post is a dynamically created page and the file name is the date is was created (I’ve made sure to address the problem of posting more than one post a day).
The problem is that I have no idea how to make the “next post” button. The “previous post” button wouldn’t be a problem since I could just link it to the most recent post during the current post’s creation. My table in the database for the blog is as follows:
num - auto increment post number
date - date posted
src - page location
I could rebuild the blog to be completely server-sided and just have one page for the blog that will cycle through each post. I don’t really want to do that though since you couldn’t send someone a direct link to an individual blog post. My other idea was to rename each page based on post number, but if we ever had to delete a post, that wouldn’t work.
I really have no idea what to do. Neither of my solutions are optimal and they will both pose problems in the future.
Thanks in advance for any help.
You write:
I strongly recommend using a database solution rather than creating static files with blog content in them. On the long run, it’s much more flexible. If you want to delete a post, edit a post, move a post, it’s just much more accessible if everything is easily accessible.
The problem you pose with not being able to direct link to blog posts can be easily circumvented: use GET-variables in your URL. If you have a PHP page to display blogposts, say, displaypost.php, you could add a variable to the end telling the page which post to display. Your url could then be: yoursite.com/displaypost.php?postid=12
That would also make your problem of linking to the previous and next posts much easier; simply check the database what the next id is, higher than the current one (or one lower).
In my opinion it’s inevitable that you switch to a database-driven solution somewhere down the road – rather soon than later, to prevent having to do stuff twice.