function Footer() {
// Check if footer for this page already exists
if(!$this->footerset[$this->page]) {
$this->SetY(-15);
//Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
// set footerset
$this->footerset[$this->page] = 1;
}
}
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;
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) {
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;
}
function connect($host='localhost',$username='',$password='',$db=''){
$this->conn = mysql_connect($host,$username,$password) or die( mysql_error() );
mysql_select_db($db,$this->conn) or die( mysql_error() );
function mysql_report($query,$dump=false,$attr=array()){
foreach($attr as $key=>$val){
$this->$key = $val ;
}
$this->query($query);
// if column widths not set
if(!isset($this->tablewidths)){
// starting col width
$this->sColWidth = (($this->w-$this->lMargin-$this->rMargin))/$this->numFields;
// loop through results header and set initial col widths/ titles/ alignment
// if a col title is less than the starting col width / reduce that column size
for($i=0;$i<$this->numFields;$i++){
$stringWidth = $this->getstringwidth(mysql_field_name($this->results,$i)) + 6 ;
if( ($stringWidth) < $this->sColWidth){
$colFits[$i] = $stringWidth ;
// set any column titles less than the start width to the column title width
}
$this->colTitles[$i] = mysql_field_name($this->results,$i) ;
switch (mysql_field_type($this->results,$i)){
case 'int':
$this->colAlign[$i] = 'R';
break;
default:
$this->colAlign[$i] = 'L';
}
}
// loop through the data, any column whose contents is bigger that the col size is
// resized
while($row=mysql_fetch_row($this->results)){
foreach($colFits as $key=>$val){
$stringWidth = $this->getstringwidth($row[$key]) + 6 ;
if( ($stringWidth) > $this->sColWidth ){
// any col where row is bigger than the start width is now discarded
unset($colFits[$key]);
}else{
// if text is not bigger than the current column width setting enlarge the column
if( ($stringWidth) > $val ){
$colFits[$key] = ($stringWidth) ;
}
}
}
}
foreach($colFits as $key=>$val){
// set fitted columns to smallest size
$this->tablewidths[$key] = $val;
// to work out how much (if any) space has been freed up
$totAlreadyFitted += $val;
}
function connect($host='localhost',$username='root',$password='123',$db='dapp_db'){
$this->conn = mysql_connect($host,$username,$password) or die( mysql_error() );
mysql_select_db($db,$this->conn) or die( mysql_error() );
return true;
}
ใส่เพิ่มเข้าไป
Code
function connect($host='localhost',$username='root',$password='123',$db='dapp_db'){
$this->conn = mysql_connect($host,$username,$password) or die( mysql_error() );
mysql_select_db($db,$this->conn) or die( mysql_error() );
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client='tis620'");
mysql_query("SET character_set_connection='tis620'");