public function maketable($query, array $extra=null) {
    $table = "<table";
    if($extra['attr']) {
      $attr = $extra['attr'];
      foreach($attr as $k=>$v) {
        $table .= " $k='$v'";
      }
    }
    $table .= ">\n<thead>\n<tr>%<th>*</th>%</tr>\n</thead>";
    $rowdesc = "<tr><td>*</td></tr>";
    $delim = array("<td>", "</td>");
    $callback = $extra['callback']; // Before
    $callback2 = $extra['callback2']; // After
    
    $tbl = $this->makeresultrows($query, $rowdesc,
                                 array('return'=>true, callback=>$callback,
                                       callback2=>$callback2, header=>$table, delim=>$delim));

    if($tbl === false) {
      return false;
    }
    
    extract($tbl);

    $ftr = $extra['footer'] ? "<tfoot>\n{$extra['footer']}\n</tfoot>\n" : null;

    $ret = <<<EOF
$header
<tbody>
$rows</tbody>
$ftr
</table>

EOF;

    return array($ret, $result, $num, $header, table=>$ret, result=>$result, num=>$num, header=>$header);
  }
public function maketable($query, array $extra=null) {
    $table = "<table";
    if($extra['attr']) {
      $attr = $extra['attr'];
      foreach($attr as $k=>$v) {
        $table .= " $k='$v'";
      }
    }
    $table .= ">\n<thead>\n<tr>%<th>*</th>%</tr>\n</thead>";
    $rowdesc = "<tr><td>*</td></tr>";
    $delim = array("<td>", "</td>");
    $callback = $extra['callback']; // Before
    $callback2 = $extra['callback2']; // After
    
    $tbl = $this->makeresultrows($query, $rowdesc,
                                 array('return'=>true, callback=>$callback,
                                       callback2=>$callback2, header=>$table, delim=>$delim));

    if($tbl === false) {
      return false;
    }
    
    extract($tbl);

    $ftr = $extra['footer'] ? "<tfoot>\n{$extra['footer']}\n</tfoot>\n" : null;

    $ret = <<<EOF
$header
<tbody>
$rows</tbody>
$ftr
</table>

EOF;

    return array($ret, $result, $num, $header, table=>$ret, result=>$result, num=>$num, header=>$header);
  }
public function maketable ( $ query , array $ extra = null ) { $ table = "<table" ; if ( $ extra [ 'attr' ] ) { $ attr = $ extra [ 'attr' ] ; foreach ( $ attr as $ k => $ v ) { $ table .= " $k='$v'" ; } } $ table .= ">\n<thead>\n<tr>%<th>*</th>%</tr>\n</thead>" ; $ rowdesc = "<tr><td>*</td></tr>" ; $ delim = array ( "<td>" , "</td>" ) ; $ callback = $ extra [ 'callback' ] ; // Before $ callback2 = $ extra [ 'callback2' ] ; // After $ tbl = $ this -> makeresultrows ( $ query , $ rowdesc , array ( 'return' => true , callback => $ callback , callback2 => $ callback2 , header => $ table , delim => $ delim ) ) ; if ( $ tbl === false ) { return false ; } extract ( $ tbl ) ; $ ftr = $ extra [ 'footer' ] ? "<tfoot>\n{$extra['footer']}\n</tfoot>\n" : null ; $ ret =  <<<EOF
$header
<tbody>
$rows</tbody>
$ftr
</table>

EOF ; return array ( $ ret , $ result , $ num , $ header , table => $ ret , result => $ result , num => $ num , header => $ header ) ; }
Make a full table

@param string $query : the table query
@param array $extra : optional.
$extra is an optional assoc array: $extra['callback'], $extra['callback2'], $extra['footer'] and $extra['attr'].
$extra['attr'] is an assoc array that can have attributes for the <table> tag, like 'id', 'title', 'class', 'style' etc.
$extra['callback'] function that can modify the header after it is filled in.
$extra['footer'] a footer string
@return array [{string table}, {result}, {num}, {hdr}, table=>{string}, result=>{result}, num=>{num rows}, header=>{hdr}]
or === false
Make a full table