This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > August 2004 > PHP Query





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author PHP Query
thlokey

2004-08-26, 12:19 pm

I have a table in my database that holds dated information. I want to make a
query in my recordset definition such that only dated information from today
forward are listed. In ASP, the function looks like this:

WHERE Date = 'Date()'

Why doesn't that work in PHP? Any help would be appreciated. Thanks.

Michael Fesser

2004-08-26, 12:19 pm

.oO(thlokey)

>I have a table in my database that holds dated information. I want to make a
>query in my recordset definition such that only dated information from today
>forward are listed. In ASP, the function looks like this:
>
> WHERE Date = 'Date()'
>
> Why doesn't that work in PHP? Any help would be appreciated. Thanks.


What database? What type is the field 'Date' of?

If it's mysql you should have a look at its date and time functions:

http://dev.mysql.com/doc/mysql/en/D..._functions.html

Micha
thlokey

2004-08-26, 12:19 pm

I'm using mySQL, but am using dreamweaver to complete the query.

I double-checked that the 'Date' field is a date field.

I tried: WHERE Date >= 'CURDATE()' without any luck. Here's the whole code:

$query_rsTRAINING = "SELECT * FROM training WHERE Date >= ' CURDATE()' ORDER
BY `Date` ASC";

Alexandru COSTIN

2004-08-26, 12:19 pm

Hi,
The right syntax should be

WHERE Date='<?php echo date('d-m-Y'); ?>'

Depending on your database type and date delimiter, you might need to have

WHERE Date=#<?php echo date('Y-m-d'); ?>#

it works for you?

Alexandru

thlokey wrote:

>I have a table in my database that holds dated information. I want to make a
>query in my recordset definition such that only dated information from today
>forward are listed. In ASP, the function looks like this:
>
> WHERE Date = 'Date()'
>
> Why doesn't that work in PHP? Any help would be appreciated. Thanks.
>
>
>

Michael Fesser

2004-08-26, 12:19 pm

.oO(thlokey)

> I tried: WHERE Date >= 'CURDATE()' without any luck. Here's the whole code:


Remove the single quotes around the CURDATE call or it will be treated
as a string by MySQL.

HTH
Micha
Sponsored Links


Copyright 2003 - 2009 forum4designers.com  Software forum  Computer Hardware reviews