well, then you have to do it with PHP, as I said - if possible, then mySQL
does it better.

Try converting each date into UNIX timestamp adding to it 60*60*24*10 . It
will create you a set of dates incremented by 10 days.


What I previously meant was :

say you design a poll, you have a table called logs.
you want to see if the specific user have already voted within the last 10
days.

SELECT date FROM logs WHERE user='$user' AND date>=(NOW() - INTERVAL 10
DAY));

this will return you at least one row (hopefully one only) if there's such a
user voted less then 10 days ago, and will return you an empty set if
there's none.

Many use PHP to do that kind of checks while mySQL has it built in.

Since I am not sure I understood your situation right, I think you should
consider some mySQL (or any other DB) date functions. They often save you a
lot of code. Otherwise try to do it with PHP as you have already resolved
it.


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-----Original Message-----
From: Martin Skjoldebrand [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 22, 2001 8:13 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Incrementing dates


PHPBeginner.com wrote:

>
> INSERT INTO table SELECT date+INTERVAL 10 DAYS AS date FROM table WHERE
> bla=bla;
>
> it is just a way to do it. you will definitely have to play with it.
>
> However you can easily make two queries to read the previous date
> combining it with INTERVAL and then do an insert.

I've looked at INTERVAL but it seems it only deals with one specific date
at a time?

date=10 : SELECT date+INTERVAL 10
would then mean date=20

Or have I got everything wrong?

What I looking at
from the value of date=10 ADD other dates for X days on, like this
(in a table, each record (row) has more data than the one given)
date=2001-04-10
date=2001-04-11
date=2001-04-12

This, if I'm mistaken can't be done with interval, at least not without
looping in PHP? And using two queries would not perhaps save as much code
as the way I solved it? Could be mistaken of course.

Martin S.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to