[PHP] Re: How make the time
>The client wants to get a report written out over each hour like this: > >11:002 Customers >11:1532 Customers >11:3012 Customers >... >... >22:3014 Customers Assuming you only allow them to put in valid :15 minute data in the first place: $query = "select time_field, count(*) from booking GROUP BY time_field order by time_field"; $bookings = mysql_query($query) or die(mysql_error()); while (list($time, $count) = mysql_fetch_row($bookings)){ echo "$time $count Customers\n"; } The GROUP BY clause "smushes" all records with the same value in that field together in a set so you can get the COUNT. Or AVERAGE on another field, or MIN or MAX or all sorts of other cool "AGGREGATE" functions. For example, the following might be a query you'd write to tell him which hours are his biggest/lowest revenue-generators: select time_field, min(bill), max(bill) from receipts group by time_field Assuming that for each reservation he had recorded their bill in the first place... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: How make the time
Thank you "Elias" <[EMAIL PROTECTED]> skrev i melding [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > select count(*) from test1 > where > MINUTE(tm1) >= 15 > and > MINUTE(tm1) <= 30 > and > HOUR(tm1)=12 > > this query will return you on column containing how many record found in > that time range, same as how many customers where surfed at that time > where 30-15=interval > and 12 is the hour you're checking in! > > "David Tandberg-Johansen" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Hello! > > > > I am trying to make an online booking script for a client (restaurant), > and > > I am using MySQL to store the booking information > > The restaurant have openings hour from 11:00 -> 01:00, but do only take > > reservation between 11:00->22:30. > > The client wants to get a report written out over each hour like this: > > > > 11:002 Customers > > 11:1532 Customers > > 11:3012 Customers > > ... > > ... > > 22:3014 Customers > > > > In the MySQL table I have set up the time field as 'time' with 00:00:00 as > > default. > > > > Everything is ok, but I am stuck on how to make this report. The customer > > have set an interval of 15 mnutes between possible time to book, so I have > > to make an 'SELECT'-query based on when the restaurant opens to the time > of > > the last possible booking time. But how do I make the timeset (11:00:00 > and > > up to 22:30:00) > > > > My far out example: > > interval = 15; > > while (time<=endtime){ > > time=starttime > > DBCONNECTION > > Select * from booking wher tine_field='time' > > time = time+interval > > } > > > > Do anyone have any tips on how I can solve this > > > > David > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: How make the time
select count(*) from test1 where MINUTE(tm1) >= 15 and MINUTE(tm1) <= 30 and HOUR(tm1)=12 this query will return you on column containing how many record found in that time range, same as how many customers where surfed at that time where 30-15=interval and 12 is the hour you're checking in! "David Tandberg-Johansen" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello! > > I am trying to make an online booking script for a client (restaurant), and > I am using MySQL to store the booking information > The restaurant have openings hour from 11:00 -> 01:00, but do only take > reservation between 11:00->22:30. > The client wants to get a report written out over each hour like this: > > 11:002 Customers > 11:1532 Customers > 11:3012 Customers > ... > ... > 22:3014 Customers > > In the MySQL table I have set up the time field as 'time' with 00:00:00 as > default. > > Everything is ok, but I am stuck on how to make this report. The customer > have set an interval of 15 mnutes between possible time to book, so I have > to make an 'SELECT'-query based on when the restaurant opens to the time of > the last possible booking time. But how do I make the timeset (11:00:00 and > up to 22:30:00) > > My far out example: > interval = 15; > while (time<=endtime){ > time=starttime > DBCONNECTION > Select * from booking wher tine_field='time' > time = time+interval > } > > Do anyone have any tips on how I can solve this > > David > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: How make the time
select count(*) from test1 where MINUTE(tm1) >= 15 and MINUTE(tm1) <= 30 and HOUR(tm1)=12 this query will return you on column containing how many record found in that time range, same as how many customers where surfed at that time where 30-15=interval and 12 is the hour you're checking in! "David Tandberg-Johansen" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello! > > I am trying to make an online booking script for a client (restaurant), and > I am using MySQL to store the booking information > The restaurant have openings hour from 11:00 -> 01:00, but do only take > reservation between 11:00->22:30. > The client wants to get a report written out over each hour like this: > > 11:002 Customers > 11:1532 Customers > 11:3012 Customers > ... > ... > 22:3014 Customers > > In the MySQL table I have set up the time field as 'time' with 00:00:00 as > default. > > Everything is ok, but I am stuck on how to make this report. The customer > have set an interval of 15 mnutes between possible time to book, so I have > to make an 'SELECT'-query based on when the restaurant opens to the time of > the last possible booking time. But how do I make the timeset (11:00:00 and > up to 22:30:00) > > My far out example: > interval = 15; > while (time<=endtime){ > time=starttime > DBCONNECTION > Select * from booking wher tine_field='time' > time = time+interval > } > > Do anyone have any tips on how I can solve this > > David > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]