# Table with MySQL

## Informations

Author: Olivier
License: FPDF

## Description

This class allows to output a table whose content comes from a MySQL query. The table header is automatically printed on top of each page.

The method to add a column is:

`AddCol([mixed field [, mixed width [, string caption [, string align]]]])`
`field`: field of the SQL query (either name or index). If -1, the column will represent the field in the same position in the query (default value).
`width`: width of the column. It can be a number giving the absolute value, or a string of the form x% to request a percentage of the table width. If -1, the width equals the table width divided by the number of columns (default value).
`caption`: caption of the column. If empty, the capitalized name of the field will be used (default value).
`align`: alignment of the column content. Possible values are `L`, `C` and `R` (default is `L`).

The method to output the table is:

`Table(mysqli link, string query [, array prop])`
`link`: the MySQLi link.
`query`: the SQL query.
`prop`: associative array containing the table properties. Possible keys are:
`width`: width of the table. Useful if you specify column widths by percentage. The default value is the page width without the margins.
`align`: alignment of the table in the page. Possible values are `L`, `C` and `R` (default is `C`).
`padding`: left and right margins used inside cells. Default value is 1mm.
`HeaderColor`: background color for the table header (array of the three RGB components).
`color1`: background color for odd rows.
`color2`: background color for even rows.
If no column has been defined when `Table()` is called, columns corresponding to all the fields of the query are added automatically.
After the output of the table, all column definitions are cleared.