count frequancy between dates!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jenny kaur
Forum Newbie
Posts: 5
Joined: Mon Jan 24, 2005 1:16 pm
Location: London, England and Tokyo, Japan

count frequancy between dates!

Post by jenny kaur »

i want to know how i would show the number of booked rooms each day over a given period.

$datein="2005-02-05";
$dateout="2005-02-09";

i tried array_count_values but didnt work.

MY Database table:

+----+--------------+---------------+
+ id.+ ..bookdate + enddate +
+----+--------------+---------------+
+ 1. + 2005-02-05 + 2005-02-06 +
+----+--------------+---------------+
+ 2. + 2005-02-05 + 2005-02-07 +
+----+--------------+---------------+
+ 3. + 2005-02-05 + 2005-02-08 +
+----+--------------+---------------+

Code: Select all

$query = "select * FROM rooms WHERE bookdate < '$dateout' AND enddate > '$datein'";
the output i woud like would be like below:

-- 2005-02-05 -- 2005-02-06 -- 2005-02-07 -- 2005-02-08
_______3___________2___________1___________0____

please help!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

possibly try

Code: Select all

$query = "select count(*) FROM rooms WHERE bookdate < '$dateout' AND enddate > '$datein'";
jenny kaur
Forum Newbie
Posts: 5
Joined: Mon Jan 24, 2005 1:16 pm
Location: London, England and Tokyo, Japan

Post by jenny kaur »

hi thanks for reply, but that will count all the booked rooms for the whole period...i want to know how many booked rooms per day in that period.

i.e:

-- 2005-02-05 -- 2005-02-06 -- 2005-02-07 -- 2005-02-08
___3 booked____2 Booked_____1 Booked____0 booked__
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

because the individual days are not stored, you may need to compute that yourself.
jenny kaur
Forum Newbie
Posts: 5
Joined: Mon Jan 24, 2005 1:16 pm
Location: London, England and Tokyo, Japan

Post by jenny kaur »

Hi Feyd,

yes i know i have to compute that myself, but how is what i am asking???
Post Reply