Display a table
Here, we have a single table of archived mailings. The data comes into this table from another source, but we want to display the archive.
First, we have to include the plug-in and connect to the database.
<? include_once("/web/includes/sql.phpi"); $spam = new MySQL('username', 'password', 'mailarchive', 'mail'); ?>
And of course we want the style sheet to make it look better:
<? $spam->HTMLHead(); ?>
We could just do $spam->displayList() and be done, but we only want to display ten messages at a time, and we want to allow focussing on a couple of fields, so that we can find, for example, all mails sent by a particular person, or all mails sent to a particular audience.
<? $spam->focusFields(array('person', 'audience', 'area')); $spam->limit(10); $spam->displayList(); ?>
We don’t specify which columns to show in the overview page and which columns to show in the detail pages. The plug-in determines that automatically from the type of each field and the size of each field. Large fields are kept out of the overview and only shown in a detail page.
So, for example, we see the message’s subject in the overview, but the message’s body only shows on a detail page.
For many databases, where all data is stored in one table, these six lines are as complex—or even more complex—as you’ll need to get. Everything else—paging, searching, focussing, and details—are all handled automatically by the plug-in.
