Occasionally when working with table data, you want to have a total for certain columns. Dealing with this can be tricky, as the total needs to be changed whenever a cell in that column is updated. Fortunately, TableGear handles all this for you in the background.
$tg = new TableGear(array( "database" => array( "username" => "USERNAME", "password" => "PASSWORD", "database" => "DATABASE", "table" => "TABLE" ), "sortable" => "all", "editable" => "all", "loading" => array( "tag" => "img", "attrib" => array( "src" => "/images/icons/loading.gif", "alt" => "Loading...", "class" => "loading" ) ), "formatting" => array( "price" => "currency[prefix=$,pad], "date" => "date" ), "totals" => array("price", 5) );
For each column we want to have a total for, we can pass a field name as it appears in the database, or a column number as it appears in the table.