Re: Automatically changing data in database
| From: | Marko Vukovic' | Date: | Thu, 24 Aug 2000 14:29:38 +0000 |
| Subject: | Re: Automatically changing data in database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13428@lists.php.net to get a copy of this message | ||
Siim Einfeldt wrote:
>
> > hmmm..ok, so how do you store the articles? Does each one have a unique and
> > sequential number?
>
> Right now the system is quite simple. There`s lots of columns in the
> database, but one of them is called today. When someone adds an article,
> the today field gets the value 'yes'. Now...when the changing should take
> place, this today changes to 'no' and next article with the value of 'yes'
> gets displayed. I hope this makes sense to you.
OK, so at 24h00, all articles with the value 'yes' in the 'today' column must
change to 'no' right?
Unless you have compiled the CGI version of php (--without-apache), I would
write a perl script that's executed by a cron job at 24h00.
I can help with the cron job, but I forget how to do db stuff in perl.
If you have installed the version of PHP that can execute from the command line,
then this should be no problem for you.
> > Come to think of it, if you store the articles by date, your php script can
> > simply check what today's date is and then fetch the corresponding article.
>
> That
s also a possibility, but right now the 'magazine'
> wont be
> anything very big and I think the easiest way to keep it, would be just to
> display the articles in order of time they were added. In future, it can
> be changed, but right now I want to make it as automatic as possible.
>
> -------------
> Siim Einfeldt
>
Would it not be simple enough to add another column for the date
eg: ALTER TABLE articles ADD COLUMN article_date date
and store the date at the same time the article is added. In this way, your
script can search the db for articles that are dated today and then only display
those.
--
Marko