No year specified'); exit(0); } /* Some variables */ $user = $_SESSION['user']; $year = $_GET['year']; $tip_totals = Array(); /* Print some header HTML */ print << TipMan Report for $year EOP; /* Do a query to get the tip totals per period */ $dbc = connect_db(); $qRes = do_query(<<'); print('MonthPeriodAmountTotal'); for ($monthIndex = 1; $monthIndex <= 12; $monthIndex++) { /* Get a timestamp for the current month */ $monthTimestamp = mktime(0, 0, 0, $monthIndex, 1, $year); /* Set the tip totals for each period to 0 if they are not set */ if (!isset($tip_totals[$monthIndex][1])) $tip_totals[$monthIndex][1] = 0; if (!isset($tip_totals[$monthIndex][2])) $tip_totals[$monthIndex][2] = 0; /* Print a row in the report table */ print(''); printf('%s', date('F', $monthTimestamp)); print('1 - 15'); printf('$%.2f', $tip_totals[$monthIndex][1]); printf('$%.2f', $tip_totals[$monthIndex][1] + $tip_totals[$monthIndex][2]); printf('16 - %d', date('t', $monthTimestamp)); printf('$%.2f', $tip_totals[$monthIndex][2]); print("\n"); /* Increment the year's total tips */ $yearTotal += $tip_totals[$monthIndex][1]; $yearTotal += $tip_totals[$monthIndex][2]; } printf(' Total:$%.2f', $yearTotal); print(''); ?>