Programming an update system that is timed based?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Programming an update system that is timed based?

Post by jonas »

So on my personal webcomic I have an update system where I put in all the comics information, write an update and such and click a button that updates the database and shows up on my pages.

What I want to do now is make it so that if I have to work late or want to go out with the girlfriend that I can write an update around 6pm (I update new content at midnight) and have it 'save' in the database and not show up until 12am.

So my site is http://www.robobo.com and it works pretty nicely so far. The newest comic has a special database field that only the newest comic has. So basically I need to setup my database and update form to 'save' an update until 12am then insert it like it does now.

Is there anyway to do this? Keep in mind, I don't want to shut down my website or make drastic modifications as I have a nice audience that I don't want to disrupt.


Thanks for any help guys. Appreciate it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I may have a tough time suggesting much without seeing how the backend is put together, but here goes:

Add or alter this "special" field, which sounds likely largely unused right now, such that it is a DATE field. You can then set a date when each entry becomes visible.

Now all you need to do is alter your fetch code to only pull entries that have today's date or earlier. You're done.
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post by jonas »

I have no doubts that my system may be inefficient but it works and works well for me.

The special field is simply a yes/no that is either newest comic = yes or not. When I update, it removes the last comics yes and the newest comic gains it becoming the newest comic.

Thanks for the suggestion though, I do have date fields and didn't think about setting them as part of the fetch code. I think it'll work great.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Use a cronjob set for 6pm to move files from a hidden/out-of-webroot "tomorrow" folder, to the webdirectory.

Then you can always update by dumping to the tomorrow folder, and the script will do it all for you. :)
Post Reply