Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
Argh, make sure you add the closing paren for the date_add since I 
forgot it.


Mike...

Mike Gohlke wrote:
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us






--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Query with numbers like 1, 3, 5..........

2002-02-07 Thread Mike Gohlke

? whatever... ?
table border=1
?
$qry = mysql_query(select * from tablename order by id);
while ( $ref1 = mysql_fetch_object($qry) ) {
$ref2 = mysql_fetch_object($qry)
?trtd$ref1-id nbsp;/tdtd$ref2-id nbsp;/td/tr?
}
?
/table

btw, the nbsp; is to keep the internal cell borders from not appearing 
using netscape.  (keeps it from being empty).

Hope this helps
Mike...

Raymond Lilleodegard wrote:

Hi again Rick! : )

It is because I am trying to list all products that I have in a  database
into a menu page. And I would like to have two products beside eachothers.
So... is it possible to get two datarows in one:

do {

} while (mysql_fetch_array() );

?? or is this a stupid way to do it?

Reagrds Raymond
- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: 'Raymond Lilleodegard' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, February 07, 2002 8:55 PM
Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5..


Yes, but the question is why?

-Original Message-
From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 1:22 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Query with numbers like 1, 3, 5..


Hi!

Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4,

6,

...?


Best regards Raymond



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

Yes, but the question is why?

-Original Message-
From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 1:22 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Query with numbers like 1, 3, 5..


Hi!

Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4,

6,

...?


Best regards Raymond



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php