Howdy all,

New here. And I've done a search. Just can't find what I'm looking for.

I have a number in some text that I want to increment every week by 100 . And, i need it done automagically.

I have thought initially of putting the number in a DB table and have a cron update it every friday but, that just seems to maybe be a bit of an overkill.

Any ideas?

Thanks in advance.

Recommended Answers

All 6 Replies

You could store the number in either a txt file (if you don't want to do the mysql connection thing just for it) or in a db and also store the date/time for which that number "expires" and it should be incremented. Then every time a user views the page you can do a check to see if the time is past the time in the file and if so, increment the number before displaying it to the user.

You want to make sure you use server time through and not the time on the users computer.

Generally when you want to automate a PHP script, be it big or small you run it in a CRON job, so that's what I'd recommend but I'm curious to see what any other peoples input will be!

how are you going to use this number? after i know this i can tell you which solution (database, txt file, ect.) would be better.

Thanks for all the quick responses.

This is basically a price that goes up by $100 every week. So, it is just getting displayed on a page.

if its something that gets repeated viewings on a page, you will need something with good performance like a database. file reading is pretty resource intensive, but you might not have a problem if its a small file.

pretty much, this one up to you. i prefer a database solution because its quicker and in my opinion easier to update and work with in general. then i would use a cron job to increment the number in the database by 100 every week.

Thank you. I have gone with a db solution with a cron. Then, I had to figure out how to put it in a wordpress doc. dynamically. But, managed that too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.