|
![](/images/resource/spacer.gif) |
|
FPDF จะทำ title ของรายงานแต่ละหน้าแต่ติด error ค่ะ : Fatal error: Call to a member function Output() on a non-object |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขึ้นเออเร่อตามนี้ค่ะ
Fatal error: Call to a member function Output() on a non-object in C:\AppServ\www\InventoryCosmetic\report-all-inventory.php on line 242
ติด $pdf->Output(); ตอนแรกลองเป็นใส่ path ให้มัน $pdf->Output("PDF/Inventory.pdf","F");
มันก็ไม่ให้ผ่านค่ะ พอลบออกก็ไม่ให้ผ่านอีก ไม่ทราบว่าจะต้องแก้ไขยังไงได้มั่งคะ
Code (PHP)
<?php
require('fpdf.php');
class PDF extends FPDF
{
$strSQL = "SELECT i.inventory_id, p.pro_name, b.brand_name, i.qty_available, i.all_income, i.unitCost, (i.all_income*i.unitCost) as total1 FROM inventory i, product p, brand b where p.inventory_id = i.inventory_id and p.brand_id = b.brand_id";
$objQuery = mysql_query($strSQL);
$rows = mysql_num_rows($objQuery);
if(rows>35){
$pdf=new PDF();
$header=array('Inventory ID','Product Name','Brand','Available','Income','Cost','Amount');
$pdf->SetMargins(10,2,10);//กำหนด Margin
$strSQL = "SELECT i.inventory_id, p.pro_name, b.brand_name, i.qty_available, i.all_income, i.unitCost, (i.all_income*i.unitCost) as total1 FROM inventory i, product p, brand b where p.inventory_id = i.inventory_id and p.brand_id = b.brand_id Limit 0,35";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//*** Table 1 ***//
$pdf->AliasNbPages( 'tp' );
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->Image('images\header\logo-inventory.png',30,8,150);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData);
}else if(rows>35 && rows<=85){
$strSQL1 = "SELECT i.inventory_id, p.pro_name, b.brand_name, i.qty_available, i.all_income, i.unitCost, (i.all_income*i.unitCost) as total1 FROM inventory i, product p, brand b where p.inventory_id = i.inventory_id and p.brand_id = b.brand_id Limit 35,85";
$objQuery1 = mysql_query($strSQL1);
$resultData1 = array();
for ($i=0;$i<mysql_num_rows($objQuery1);$i++) {
$result1 = mysql_fetch_array($objQuery1);
array_push($resultData1,$result1);
}
//*** Table 2 ***//
$pdf->AliasNbPages( 'tp' );
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->Image('images\header\logo-inventory.png',30,8,150);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData1);
}else if(rows>85 && rows<=135){
$strSQL2 = "SELECT i.inventory_id, p.pro_name, b.brand_name, i.qty_available, i.all_income, i.unitCost, (i.all_income*i.unitCost) as total1 FROM inventory i, product p, brand b where p.inventory_id = i.inventory_id and p.brand_id = b.brand_id Limit 85,135";
$objQuery2 = mysql_query($strSQL2);
$resultData2 = array();
for ($i=0;$i<mysql_num_rows($objQuery2);$i++) {
$result2 = mysql_fetch_array($objQuery2);
array_push($resultData2,$result2);
}
//*** Table 3 ***//
$pdf->AliasNbPages( 'tp' );
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->Image('images\header\logo-inventory.png',30,8,150);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData2);
}else if(rows>135 && rows<=185){
$strSQL3 = "SELECT i.inventory_id, p.pro_name, b.brand_name, i.qty_available, i.all_income, i.unitCost, (i.all_income*i.unitCost) as total1 FROM inventory i, product p, brand b where p.inventory_id = i.inventory_id and p.brand_id = b.brand_id Limit 135,185";
$objQuery3 = mysql_query($strSQL3);
$resultData3 = array();
for ($i=0;$i<mysql_num_rows($objQuery3);$i++) {
$result2 = mysql_fetch_array($objQuery3);
array_push($resultData3,$result3);
}
//*** Table 4 ***//
$pdf->AliasNbPages( 'tp' );
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->Image('images\header\logo-inventory.png',30,8,150);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData3);
}
$pdf->Output();
?>
Tag : PHP
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-02-10 11:03:22 |
By :
Mintiiz |
View :
753 |
Reply :
3 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
จัดเรียงลำดับ if ผิด
Code (PHP)
if(rows>35){
//...
}else if(rows>35 && rows<=85){
//....
}else if(rows>85 && rows<=135){
//....
}else if(rows>135 && rows<=185){
//....
}
จากโค๊ดข้างบน ทำแค่ อันเดียว คือ อันบนสุด
3 อันล่างไม่มีโอกาสทำ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-02-10 20:21:00 |
By :
Chaidhanan |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขอบคุณมากค่ะ ![](/images/bbcode/roll.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-02-13 16:29:01 |
By :
Mintiiz |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 02
|