Re: [PHP] Date again

2002-12-06 Thread Jason Wong
On Saturday 07 December 2002 11:39, Miguel Brás wrote:
> Ok guys,
>
> having a problem here. I did my table with 6 fields, they are:
> id  position  name  timein  timeout  date
>
> I have a form to insert the info on the fields, and at the date field, I
> have a drop down menu that returns me the next 7 days (the date in d/m/y),
> people will choose the date they want and that will be stored on the table.
>
> Now I want to retrieve the position, name, timein and timeout from by table
> and display it on a page. But I want only the records for the present date.
> I inserted the info on my table and on the date's field I inserted 07/12/02
> and 06/12/02 just for testing
>
> I called the data via a query: SELECT position, name, timein, timeout, date
> FROM table WHERE date=NOW()
> It was supposed that only the record from the present date was shown. But
> not, I can't have anything. Only the custom message I did if nothing was
> available

NOW() returns the current date and TIME. Use CURRENT_DATE or CUR_DATE() to get 
just the date portion.

> One more thing, how can I do to prevent that different people apply for a
> same position, on the same day and during the "shift" of the first one that
> applied?

Check the archives, there was a thread in the last couple of days about 
"Checking for Overlapping Dates". The same principles should apply so it may 
be useful reading.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Abstainer, n.:
A weak person who yields to the temptation of denying himself a
pleasure.
-- Ambrose Bierce, "The Devil's Dictionary"
*/


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




Re: [PHP] Date again

2002-12-06 Thread Stephen
Not sure but I think now() doesn't return the date formate you'd want
assuming your date section is classified as a date. Here's what I would do:

$date = date("Y-m-d");
$sql = "SELECT * FROM table WHERE date='".$date"'";
$result = mysql_query($sql, $connection);

Hope it works!


- Original Message -
From: "Miguel Brás" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 06, 2002 10:39 PM
Subject: [PHP] Date again


> Ok guys,
>
> having a problem here. I did my table with 6 fields, they are:
> id  position  name  timein  timeout  date
>
> I have a form to insert the info on the fields, and at the date field, I
> have a drop down menu that returns me the next 7 days (the date in d/m/y),
> people will choose the date they want and that will be stored on the
table.
>
> Now I want to retrieve the position, name, timein and timeout from by
table
> and display it on a page. But I want only the records for the present
date.
> I inserted the info on my table and on the date's field I inserted
07/12/02
> and 06/12/02 just for testing
>
> I called the data via a query: SELECT position, name, timein, timeout,
date
> FROM table WHERE date=NOW()
> It was supposed that only the record from the present date was shown. But
> not, I can't have anything. Only the custom message I did if nothing was
> available
>
> What is missing here? Looked at PHP manual, time, date mktime and so on
> functions, but nothing.
> Anybody for a hand?
>
> One more thing, how can I do to prevent that different people apply for a
> same position, on the same day and during the "shift" of the first one
that
> applied?
>
> I mean, I decide to occupy the FSS position from 21:00 to 23:00 on 08th
> Decemeber.
> Someone come and try to apply also for FSS but from 19:00 to 20:30 or from
> 21:30 to 22:30. Since the position is occupied during a portion of the
> requested time or during all the requested time, how can I prevent this to
> be added on the table??
>
> Thx
> Miguel
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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