Re: Статистика.
function morepagestable($lineheight=8) {
// some things to set and 'remember'
$l = $this->lMargin;
$startheight = $h = $this->GetY();
$startpage = $currpage = $this->page;
// calculate the whole width
foreach($this->tablewidths as $width) {
$fullwidth += $width;
}
// Now let's start to write the table
$row = 0;
if ($this->db_type=="mysql"){
while($data=mysql_fetch_row($this->results)) {
$this->page = $currpage;
// write the horizontal borders
$this->Line($l,$h,$fullwidth+$l,$h);
// write the content and remember the height of the highest col
foreach($data as $col => $txt) {
$this->page = $currpage;
$this->SetXY($l,$h);
$this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,$this->colAlign[$col]);
$l += $this->tablewidths[$col];
if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
$tmpheight[$row.'-'.$this->page] = $this->GetY();
}
if($this->page > $maxpage)
$maxpage = $this->page;
unset($data[$col]);
}
// get the height we were in the last used page
$h = $tmpheight[$row.'-'.$maxpage];
// set the "pointer" to the left margin
$l = $this->lMargin;
// set the $currpage to the last page
$currpage = $maxpage;
unset($data[$row]);
$row++ ;
}
}else{
while($data=pg_fetch_row($this->results)) {
$this->page = $currpage;
// write the horizontal borders
$this->Line($l,$h,$fullwidth+$l,$h);
// write the content and remember the height of the highest col
foreach($data as $col => $txt) {
$this->page = $currpage;
$this->SetXY($l,$h);
$this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,$this->colAlign[$col]);
$l += $this->tablewidths[$col];
if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
$tmpheight[$row.'-'.$this->page] = $this->GetY();
}
if($this->page > $maxpage)
$maxpage = $this->page;
unset($data[$col]);
}
// get the height we were in the last used page
$h = $tmpheight[$row.'-'.$maxpage];
// set the "pointer" to the left margin
$l = $this->lMargin;
// set the $currpage to the last page
$currpage = $maxpage;
unset($data[$row]);
$row++ ;
}
}
// draw the borders
// we start adding a horizontal line on the last page
$this->page = $maxpage;
$this->Line($l,$h,$fullwidth+$l,$h);
// now we start at the top of the document and walk down
for($i = $startpage; $i <= $maxpage; $i++) {
$this->page = $i;
$l = $this->lMargin;
$t = ($i == $startpage) ? $startheight : $this->tMargin;
$lh = ($i == $maxpage) ? $h : $this->h-$this->bMargin;
$this->Line($l,$t,$l,$lh);
foreach($this->tablewidths as $width) {
$l += $width;
$this->Line($l,$t,$l,$lh);
}
}
// set it to the last page, if not it'll cause some problems
$this->page = $maxpage;
}
|