|
|
|
การส่งไปข้อมูลไปอีกหน้าหนึ่ง แต่โชว์อีกหน้าหนึ่งขึ้นมาแสดง |
|
|
|
|
|
|
|
ต้องการส่งข้อมูลไปหน้า นี้ แต่จะให้โชว์อีกหน้าที่เป็น pdf อ่าค่ะ จะทำยังไงก็ไม่ได้ซักทีCode (PHP)
<html>
<link href="bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<?
session_start();
$con = mysqli_connect($host, $user, $password,$database);
mysqli_set_charset($con,"utf8");
$aar = $_POST["chk"];
$com_id = implode(",", $aar);
for($i=0;$i<count($_POST["chk"]);$i++)
{
if(trim($_POST["chk"][$i]) != "")
{
$sql = "SELECT * from ThaiIDCard Where id IN ($com_id) order by id";
}
else {
$sql = "SELECT * from ThaiIDCard order by id";
}
}
if ($sql==""){
$sql = "SELECT * from ThaiIDCard order by id";
}
$sqlQ = mysqli_query($con,$sql) or die ("Error Query [".$sql."]");
?>
<div class="container">
<div class="row">
<?php
$i=1;while($sqlR = mysqli_fetch_array($sqlQ)){ ?>
<div class="col-md-4">
<div class="media d-md-inline-flex ">
<img class="mr-3 rounded-circle align-self-center mr-3" src="data:image/jpg;base64,<?php echo $sqlR['photo'];?>" alt="Generic placeholder image" width="80" hight="80">
<div class="media-body">
<p class="mb-0">
<h5> <?php echo $sqlR['titleT']." ".$sqlR['nameT']?></h6>
<?php echo $sqlR['surnameT']?><br />
<?php echo $sqlR['idnum']?><br />
<?php echo $sqlR['birthdate']?><br />
<?php echo $sqlR['province']?><br />
</p>
</div>
</div>
</div> <?php $i++; }?>
</div>
</div>
</div>
</div>
<? header('location:genpdf2.php') ?>;
</html>
หน้าที่จะให้โชว์ จะเป็นหน้าที่เป็น pdf อ่าค่ะ
Code (PHP)
<?php
require_once('tcpdf/tcpdf.php');
include("tcpdf/class/class_curl.php");
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('ninenik');
$pdf->SetTitle('TCPDF table report');
$pdf->SetSubject('TCPDF ทดสอบ');
$pdf->SetKeywords('TCPDF, PDF, ทดสอบ,ninenik, guide');
$pdf->SetHeaderData(
PDF_HEADER_LOGO,
PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE,
PDF_HEADER_STRING,
array(0,0,0),
array(0,0,0)
);
$pdf->setFooterData(
array(0,64,0),
array(220,44,44)
);
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setFontSubsetting(true);
$pdf->SetFont('thsarabun', '', 14, '', true);
$pdf->AddPage();
$path_info = pathinfo($_SERVER['REQUEST_URI']);
$http = ($_SERVER['REQUEST_SCHEME'])?$_SERVER['REQUEST_SCHEME']."://":"http://";
$host = $_SERVER['SERVER_NAME'];
$pathDir = $path_info['dirname']."/";
$url = $http.$host.$pathDir;
$html = curl_get($url."genpdf.php");
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
$pdf->Output('table_report.pdf', 'I');
?>
?>
Tag : PHP
|
ประวัติการแก้ไข 2019-01-30 11:54:39
|
|
|
|
|
Date :
2019-01-30 11:51:04 |
By :
yanikanaja |
View :
1037 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 1 เขียนโดย : nobetaking เมื่อวันที่ 2019-01-30 13:27:24
รายละเอียดของการตอบ ::
ลองแล้วค่ะ ขาวโพลนเลย 5555
Code (PHP)
<html>
<head>
<title>ThaiIDCloud</title>
</head>
<body>
<?php
require('fpdf181/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["id"],1);
$this->Cell(30,6,$eachResult["nameT"],1);
$this->Cell(55,6,$eachResult["nameE"],1);
$this->Cell(25,6,$eachResult["province"],1,0,'C');
$this->Cell(20,6,$eachResult["idnum"],1);
$this->Cell(20,6,$eachResult["reader"],1);
$this->Ln();
}
}
//Better table
function ImprovedTable($header,$data)
{
//Column widths
$w=array(20,30,55,25,25,25);
//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(20,6,$eachResult["id"],1);
$this->Cell(30,6,$eachResult["nameT"],1);
$this->Cell(55,6,$eachResult["nameE"],1);
$this->Cell(25,6,$eachResult["province"],1,0,'C');
$this->Cell(25,6,$eachResult["idnum"],2);
$this->Cell(25,6,$eachResult["reader"],2);
$this->Ln();
}
//Closure line
$this->Cell(array_sum($w),0,'','T');
}
//Colored table
function FancyTable($header,$data)
{
//Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Header
$w=array(20,30,55,25,25,25);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
//Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
//Data
$fill=false;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
$this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);
$this->Cell($w[4],6,number_format($row[4]),'LR',0,'R',$fill);
$this->Cell($w[5],6,number_format($row[5]),'LR',0,'R',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF();
//Column titles
$header=array('id','nameT','nameE','province','idnum','reader');
//Data loading
//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
$objDB = mysql_select_db("aunjaic1_TDASampleY");
$aar = $_POST["chk"];
$com_id = implode(",", $aar);
for($i=0;$i<count($_POST["chk"]);$i++)
{
if(trim($_POST["chk"][$i]) != "")
{
$sql = "SELECT * from ThaiIDCard Where id IN ($com_id) order by id";
}
else {
$sql = "SELECT * from ThaiIDCard order by id";
}
}
if ($sql==""){
$sql = "SELECT * from ThaiIDCard order by id";
}
$objQuery = mysql_query($sql);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//************************//
$pdf->SetFont('Arial','',10);
//*** Table 1 ***//
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->BasicTable($header,$resultData);
//*** Table 2 ***//
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->ImprovedTable($header,$resultData);
//*** Table 3 ***//
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData);
$pdf->Output("MyPDF/MyPDF.pdf","F");
?>
PDF Created Click <a href="MyPDF/MyPDF.pdf">here</a> to Download
</body>
</html>
|
ประวัติการแก้ไข 2019-01-30 14:33:56 2019-01-30 14:34:07
|
|
|
|
Date :
2019-01-30 14:32:51 |
By :
yanikanaja |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มี Error อะไรป่าวครับ
|
|
|
|
|
Date :
2019-01-30 14:47:28 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ได้แล้วค่ะ ใช้ TCPDF แต่เขียนอีกแบบเอา
|
|
|
|
|
Date :
2019-01-30 17:45:31 |
By :
yanikanaja |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|