>The client wants to get a report written out over each hour like this:
>
>11:00 2 Customers
>11:15 32 Customers
>11:30 12 Customers
>...
>...
>22:30 14 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<BR>\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]