开发者

Error in exporting to PDF document using PHP from MYSQL database

开发者 https://www.devze.com 2023-03-12 02:21 出处:网络
my code is generating the pdf document file but the output in PDF is printed as variable only not the value in the database. Can someone look whats the problem?

my code is generating the pdf document file but the output in PDF is printed as variable only not the value in the database. Can someone look whats the problem?

require('fpdf.php');

    mysql_connect("localhost","user","pwd") or die("Couldn't connect!"开发者_如何学JAVA);
    mysql_select_db("db_name") or die("Couldn't find db");

$pdf=new FPDF();
$pdf->AddPage();

$data = mysql_query("SELECT * FROM sold WHERE imei = '87712839712893'");

while ($result = mysql_fetch_assoc($data))
{
    $pdf->SetFont('arial','B',10);
    $pdf->Cell(40,40,'$result["saledate"]');
    $pdf->SetFont('arial','B',30);
    $pdf->Cell(40,10,'$result["sellingprice"]');
}

// I don't know if the pdf Cell() command numeric arguments need to change or not. If they do, change them.

$pdf->Output();


You are using single quotes:

$pdf->Cell(40,40,'$result["saledate"]');

leading to the variables not getting parsed.

Use double quotes instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消