Hi all,
I am trying to write a script that produces a PDF file using FPDF.
The script uses a query to return the required records and then outputs to a PDF.
I want to be able to substitute a column name with a variable in the WHERE clause. For some reason the code I have so far will not work.
$pdf=new PDF();
$pdf->AddPage();
$pdf->AddCol('Room',15,'Room','15');
$pdf->AddCol('AuditBy',40,'Audit by');
$pdf->AddCol('LastAudit',40,'Audit date','L');
$pdf->AddCol('{$_SESSION["s"]}',15,'Seq ID','C');
$pdf->AddCol('Comments13',60,'Comments','L');
//First table: put all columns automatically
$query = "
SELECT UniqueID, HotelID, Room, AuditBy, LastAudit, Complete FROM Room_Hist WHERE '{$_SESSION['s']}' = 1 AND Complete = 1 AND Fail = 1
ORDER BY Room ASC
";
$pdf->Table($query);
$pdf->Output();
Looking at the query itself:
[php
SELECT UniqueID, HotelID, Room, AuditBy, LastAudit, Complete FROM Room_Hist WHERE '{$_SESSION['s']}' = 1 AND Complete = 1 AND Fail = 1 ORDER BY Room ASC
[/code]
you can see where I am trying to perform the substitution.
WHERE '{$_SESSION['s']}' = 1
I know the the session var holds the correct data, can any one see why this should not work.
Any help would be great.
Regards,
Blackbox