On Friday 14 March 2003 22:33, Brad Wright wrote:

> I want to pull all data out of a mysql table that falls between two dates
> (a start-time and end-time).
>
> I use PHP to allow the user to specify the time interval, creating 2
> variables
> 'startTime' and 'endTime'. These are formatted thus: 2002-02-25 00:00:00
> (YYYY-MM-DD HH:mm:ss).
>
> I then use the syntax:
> $query = "select * from Job_TB where teamNo = $teamNo AND startTime >=
> $timeFrom AND endTime <= $timeTo";

Try enclosing the dates with single-quotes (they are strings).

> $result = mysql_query($query,$db) or die ("somethings wrong");

Try using mysql_error() to see _what_ went wrong instead of just reporting 
that _something_ went wrong.

Also consider using BETWEEN (check mysql manual).

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
The onset and the waning of love make themselves felt in the uneasiness
experienced at being alone together.
                -- Jean de la Bruyere
*/


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

Reply via email to