Weird class problem I think
Posted: Sat Aug 16, 2003 12:16 am
ok guys. I am using fpdf (http://www.fpdf.org) to convert info from a mysql database to the pdf file.
This is my code:
Now, all of the variables that I set up top (such as $vin) are actually set and do contain a value. But if I do something like displaying the variable in the actual class parameters, its as if it is not set... I tried moving the spot where the queries run, but still cant get it to work
any help is greatly appreciated!!!
This is my code:
Code: Select all
$temp = mysql_query("SELECT * FROM images WHERE id=$id") or die("<br>" . mysql_errno().": ".mysql_error()."<br>"); //check if query successful, if not print error
$imageOverall = mysql_fetch_assoc($temp);
$image_Filename = $imageOverallї'filename'];
$image_Width = $imageOverallї'width'];
$image_Height = $imageOverallї'height'];
// print "$image, $image_Filename, $image_Width, $image_Height";
$temp = mysql_query("SELECT * FROM vehicles WHERE id=$id") or die("<br>" . mysql_errno().": ".mysql_error()."<br>"); //check if query successful, if not print error
$vehicleOverall = mysql_fetch_assoc($temp);
$description = $vehicleOverallї'description'];
$nadaPrice = $vehicleOverallї'price'];
$model = $vehicleOverallї'model'];
$mileage = $vehicleOverallї'miles'];
$vin = $vehicleOverallї'vin'];
// $vin="99999";
// print "$description, $nadaPrice, $model, $mileage, $vin";
$temp = mysql_query("SELECT * FROM saleprice WHERE id=$id") or die("<br>" . mysql_errno().": ".mysql_error()."<br>"); //check if query successful, if not print error
$salepriceOverall = mysql_fetch_assoc($temp);
$salePrice = $salepriceOverallї'price'];
$query = "SELECT name FROM features WHERE ID=$id;";
$temp = mysql_query($query, $link) or die("<br>" . mysql_errno().": ".mysql_error()."<br>"); //check if query successful, if not print error
$features = mysql_fetch_assoc($temp);
$result = mysql_query("SELECT * FROM features_lookup WHERE vid='$id' AND fid='$oid'");
if (mysql_num_rows($result)) {
$features = mysql_fetch_assoc($result);
$fid=$featuresї'fid'];
$result2 = mysql_query("SELECT * FROM features WHERE id='$fid'");
$total_features="";
while($features = mysql_fetch_assoc($result)){
$total_features = $total_features." ";
$total_features = $total_features.$features;
}
}
define('FPDF_FONTPATH','font/');
require('fpdf.php');
class PDF extends FPDF
{
//Page header
function Header()
{
global $vin;
$this->Rect(5, 5, 200, 280);
// $this->Image($image_Filename,0,0,$image_Width,$image_Height);
//Arial bold 15
$this->SetFont('Arial','B',15);
//Move to the right
$this->Cell(125);
$this->Ln(5);
//Move to the right
$this->Cell(125);
$this->Cell(60,5,'Dealership',0,0,'1');
$this->Ln(5);
//Arial bold 15
$this->SetFont('Arial','',15);
//Move to the right
$this->Cell(125);
$this->Cell(60,5,'100 My Street ',0,0,'1');
$this->Ln(5);
//Move to the right
$this->Cell(125);
$this->Cell(60,5,'City ST, 28033 ',0,0,'1');
$this->Ln(5);
//Move to the right
$this->Cell(125);
$this->Cell(60,5,$number,0,0,'1');
$this->Ln(5);
//Line break
$this->Ln(15);
//Title
$this->Cell(65,4,'Some Dynamic Info Here!',0,0,'1');
//Move to the right
$this->Cell(10);
//Arial bold 15
$this->SetFont('Arial','b',13);
//Title
$this->Cell(140,4,$model,0,0,'1');
//Line break
$this->Ln(6);
//Move to the right
$this->Cell(75);
//Arial bold 15
$this->SetFont('Arial','',13);
//Title
$this->Cell(160,4,'VIN:'.$vin ,0,0,'1');
//Line break
$this->Ln(6);
//Move to the right
$this->Cell(75);
//Title
$this->Cell(160,4,'Miles:'.$mileage ,0,0,'1');
//Move to the right
$this->Cell(90);
//Title
$this->Cell(160,4,'ad',0,0,'1');
//Line break
$this->Ln(6);
//Arial bold 15
$this->SetFont('Arial','b',12);
//Title
$this->Cell(200,4,"Vehicle Description: $description",0,0,'1');
$this->SetFont('Arial','',12);
//Line break
$this->Ln(6);
//Arial bold 15
$this->SetFont('Arial','',12);
//Title
$this->Write(5,'I throoughly enjoyed this car, it is a fun too car too drive and you know I would never sell a car that I didnt want in my own collection');
//Line break
$this->Ln(10);
//Arial bold 15
$this->SetFont('Arial','b',12);
//Title
$this->Cell(200,4,"Features:$total_features",0,0,'1');
$this->SetFont('Arial','',12);
//Line break
$this->Ln(6);
//Title
$this->Write(5,'This car is cool, I have ridden in it for many years, and always enjoy a good old fashioned ride in it. I would never sell anything that I wouldnt want in my own collection! and thats the truth!');
//Line break
$this->Ln(14);
//Move to the right
$this->Cell(50);
//Arial bold 15
$this->SetFont('Arial','',18);
//Title
$this->Cell(160,4,"NADA:$nadaPrice" ,0,0,'1');
//Line break
$this->Ln(5);
//Move to the right
$this->Cell(50);
//Arial bold 15
$this->SetFont('Arial','',18);
//Title
$this->Cell(160,4,"Our Prices: $salePrice" ,0,0,'1');
//Line break
$this->Ln(12);
//Arial bold 15
$this->SetFont('Arial','',9);
//Title
$this->Cell(195,4,'Terms and condition can go here.',1,0,'1');
}
}
//Instanciation of inherited class
$pdf=new PDF();
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->Output();
?>Now, all of the variables that I set up top (such as $vin) are actually set and do contain a value. But if I do something like displaying the variable in the actual class parameters, its as if it is not set... I tried moving the spot where the queries run, but still cant get it to work
any help is greatly appreciated!!!