<? 
require_once('connect.php'); 
	mysql_connect($host,$user,$pw) or die("ติดต่อ HOST ไม่ได้");
	mysql_select_db($dbname) or die("ไม่สามารถติดต่อฐานข้อมูลได้");
	mysql_query("SET character_set_results=tis620");
	mysql_query("SET character_set_client='tis620'");
	mysql_query("SET character_set_connection='tis620'");
	mysql_query("collation_connection = tis620_thai_ci");
	mysql_query("collation_database = tis620_thai_ci");
	mysql_query("collation_server = tis620_thai_ci");

require('fpdf.php'); 

$pdf=new PDF(); 
$pdf->AddPage(); 

class PDF extends FPDF
{

function Header()
{

	$this->Image('seafdec_logo.gif',135,8,30,30);

	$this->SetFont('CordiaNew','B',16);

	$this->Ln(30); 
		
	$this->Cell(0,7,'List Of Species',0,0,'C');
		
	$this->Ln(10);

$this->SetFont('Arial','',10);
$this->SetTextColor(0,0,0); 
$this->Cell(10,7,'spid',1,0,'C'); 
$this->Cell(70,7,'family',1,0,'C'); 
$this->Cell(10,7,'Scientific Name',1,0,'C'); 
$this->Cell(55,7,'Local Name',1,0,'C'); 
$this->Cell(30,7,'Common Name',1,0,'C'); 

}
}

$pdf=new PDF('L' , 'mm' , 'A4' ); 
$pdf->AddPage(); 

$strSQL1 = "SELECT spid,family,scientific,local,common  FROM fishspecies";
		
		$objQuery1=mysql_db_query($dbname,$strSQL1); 
		$num1=mysql_num_rows($objQuery1); 
			$t = 1;
		while($objResult1 = mysql_fetch_array($objQuery1))
		{
			
$pdf->Cell(10,7,''.$t,1,0,'C'); 
$pdf->Cell(70,7,$objResult1[family],1,0,'L'); //ชื่อ
$pdf->Cell(10,7,$objResult1[scientific],1,0,'C'); 
$pdf->Cell(55,7,$objResult1[local],1,0,'L'); 

if($objResult1[common]==""){
$pdf->Cell(30,7,' - ',1,0,'L');
}else{
$pdf->Cell(30,7,'  '.$objResult1[common],1,0,'L');
}


$t++ ;
}



$pdf->Output(); 
	

// JavaScript Document
?> 

