|
 |
|
รบกวนดูเรื่องการวนเก็บข้อมูลลง pdf ให้หน่อยคะ เก็บไม่ถูกคะ |
|
 |
|
|
 |
 |
|
จะเลือกก่อนนะค่ะว่าเอาอันไหน จากหน้านี้

พอเลือกเสดก้จะให้เก็บข้อมูลของแต่ล่ะชื่อลง pdf แต่ตอนนี้ไม่รู้ว่าจะทำยังไง
ให้เวลาขึ้นหัวข้อใหม่ให้มี ชื่อของตารางที่เลือกมาอยู่ข้างบนและตามด้วยหัวตารางและข้อมูลคะ
ไม่รู้จะวนตรงไหน โค้ดเรื่องทำpdf ก็แกะมาจากของตัวอย่างอ่าค่ะ
อยากให้เป็นแบบภาพนี้ค่ะ
\/\/\/\/\/
\/\/\/\/
\/\/
\/

แต่ตอนนี้เป็นแบบนี้
\/\/\/\/
\/\/
\/

Code (PHP)
<html>
<head>
<title>PDF</title>
</head>
<body>
<?
require('./fpdf/fpdf.php');
class PDF extends FPDF
{
//Load data
function LoadData($file)
{
//Read file lines
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
//Simple table
function BasicTable($header,$data)
{
//Header
$w=array(30,30,55,25,20,20);
//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C');
$this->Ln();
//Data
foreach ($data as $eachResult)
{
$this->Cell(30,6,$eachResult["IP"],1);
$this->Cell(30,6,$eachResult["DATE"],1);
$this->Cell(55,6,$eachResult["TIME"],1);
$this->Ln();
}
}
}
$file_name = date("D-d-M-y-H-i-s");
$pdf=new PDF();
//Column titles
$header=array('IP','DATE','TIME');
//Data loading
//*** Load MySQL Data ***//
//////////////// connect db/////////////////
$host = "127.0.0.1";
$user = "root";
$passwd = "1234";
$dbname = "dbweb";
mysql_connect($host,$user,$passwd) or die("cannot connect host");
mysql_select_db($dbname) or die("cannot connect database");
mysql_query("set NAMES utf8");
$resultData = array();
for($i=0;$i<count($_POST["chkDel"]);$i++)
{
//$title= $_POST['chkDel'][$i];
if($_POST["chkDel"][$i] != "")
{
$sqlip = mysql_query("select * from peerlist where FILENAME ='".$_POST["chkDel"][$i]."' and DOMAIN = '$domain_name'" );
while($result=mysql_fetch_array($sqlip)){
array_push($resultData,$result);
}
}
}
//************************//
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',16);
//*** Table 1 ***//
$pdf->AddPage();
//$pdf->Cell(10,10,$msg);
//$pdf->Cell(10,30,$title);
$pdf->Ln(50);
$pdf->BasicTable($header,$resultData);
$pdf->Output("MyPDF/".$file_name.".pdf","F");
?>
</body>
</html>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2011-02-19 14:58:55
|
 |
 |
 |
 |
Date :
2011-02-19 14:10:37 |
By :
pinkladyz |
View :
947 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|