function showSummary($query) { global $db_conn; print '<table align="center" border="1">'; // print table column headers $tableHeaders = array("id", "Name", "Phone #", "Email", "Points", "Details"); writeTableHeader($tableHeaders); // retrieve all data from the database to be displayed $result = $db_conn->query($query); if ($result == true) { $result->data_seek(0); while ($row = $result->fetch_assoc()) { $id = $row[tcCustomer::$custIdStr]; $fname = $row[tcCustomer::$fnameStr]; $lname = $row[tcCustomer::$lnameStr]; $phone = $row[tcCustomer::$phoneStr]; $email = $row[tcCustomer::$emailStr]; $totalPtrs = tcVisits::getTotalPointsById($db_conn, $id); writeTRBegin(); writeTD('<a href="' . 'editcustomer.php?custId=' . $id . '">' . $id . '</a>'); writeTDArray(array("{$fname} {$lname}", $phone, $email)); writeTD($totalPtrs, "right"); writeTD('<a href="' . 'showdetails.php?custId=' . $id . '">Details</a>'); writeTREnd(); } $result->free(); } else { exit("Unable to access the database."); } print "</table>"; }
public function showDetailTable() { print '<table align="center" border="1">'; // write the table header information writeTableHeader(array("Name", "Phone", "Email", "Date", "Points")); // write the table row to the web page writeTRBegin(); writeTDArray(array("{$this->fname} {$this->lname}", $this->phone, $this->email)); print '<td colspan=2></td>'; writeTREnd(); $visits = new tcVisits($this->custId, $this->db_conn); $visits->initVisits(); $numVisits = count($visits->visits); // NOTE: rowspan number has to plus 2 for unknown reason print '<td colspan=3 rowspan=' . ($numVisits + 2) . '></td>'; for ($i = 0; $i < $numVisits; ++$i) { writeTRBegin(); writeTD($visits->visits[$i]->dtime); writeTD($visits->visits[$i]->point, "right"); writeTREnd(); } $totalPtrs = tcVisits::getTotalPointsById($this->db_conn, $this->custId); writeTRBegin(); writeTD("Balance:"); writeTD($totalPtrs, "right"); writeTREnd(); print '</table>'; }