2017-05-27 17 views
0

我从我的清单调用值并将其显示在我的fpdf表单中有问题。使用PHP显示从清单到FPDF表单的倍数值

这是我fpdf_process.php:

<?php 

    if(!empty($_POST['btn_submit'])) 
    { 
     $name= $_POST['name']; 
     $mobile = $_POST['mobile']; 
     $address = $_POST['address']; 
    } 
    require("fpdf/fpdf.php"); 

    $pdf= new FPDF(); 
    $pdf->Addpage(); 
    $pdf->SetFont('Times',"", 12); 
    $pdf->Cell(0,10,"Welcome",1,1, 'C'); 
    $pdf->Cell(40,10, "Name:", 0,0); 
    $pdf->Cell(50,10, "$name", 0,1); 
    $pdf->Cell(40,10,"Mobile:",0,0); 
    $pdf->Cell(50,10, "$mobile", 0,1); 
    $pdf->Cell(40,10,"Address:",0,0); 
    $pdf->Cell(50,10, "$address", 0,1); 

    if (!empty($_POST['language[]'])) 
    { 
     foreach ($_POST['language[]'] as $selected) 
     { 
     $pdf->Cell(40,10,"$selected ", 0,1); 
     } 
    } 

    $pdf->output(); 
?> 

选定的清单不会显示fpdf_process.php PDF

请帮助我。谢谢

+1

使用http://php.net/manual/en/function.error-reporting.php你有错误和HTML(表单)是未知的。 '$ _POST ['language []'更具体。 –

回答

0

要获得$ _POST值,你必须知道数组的。

使用此

$_POST['language'][0]; 

确保您指定的字段也

type='checkbox' name='language[]' 

这也将帮助你,如果你看看POST值明白这一点。

print_r($_POST); 
+0

我做了$ _POST ['language'] [0];并遵循你所说的,但没有奏效。然后我删除了'foreach',即使你选择了很多,它也只显示一个选中的复选框。 –

+0

在每个你不需要[0]。 –

+1

这有助于! Thankyouuuuu! –