<select name"nom[]" id="nom" multiple >
<option value="BlackTrap">Blacktrap</option>
<option value="Murrum">Murrum</option>
<option value="Odinary Clay">Ordinary Clay </option>
<option value="Lignite">Lignite</option>
<option value="Odinary Send">Ordinary Send</option>
<option value="Limestone">Limestone</option>
<option value="Earth Bricks">Earth Bricks</option>
<option value="Greval">Greval</option>
<option value="Silica Sand">Silica Sand</option>
<option value="Hard moroum">Hard moroum</option>
<option value="Dolo Might">Dolo Might</option>
<option value="None">None</option>
</select>
以下代码是php。
class PDF extends FPDF
{
// Page header
function Header()
{
//$ID = $_POST['ID'];
// Logo
$this->Image('logo.jpg',25,10,175);
// Arial bold 12
$this->SetFont('Arial','B',12);
$this->Cell(100,80,'No/GS/'.$_POST["Reg"].'/'.$_POST["no"].'/'.$GLOBALS['last_id'],0,0,'C'); $this->Cell(150,80,'Dt.'. date("d/m/Y"),0,0,'C');
$this->Ln(5);
$this->Cell(200,100,'Registration for Grant of registrantion',0,0,'C');
// Line break
$this->Ln(60);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-12);
// Arial italic 8
$this->SetFont('Arial','B',12);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','B',14);
$pdf->SetX(30);
//$pdf->Cell(25,12,'Registration: '.$_POST["Reg"],0,1);
//$pdf->Cell(25,12,'Nomber: '.$_POST["no"],0,1);
$pdf->Cell(25,12,'Name Of Applicant: '.$_POST["name"],0,1);
$pdf->SetX(30);
$pdf->Cell(25,12,'Address: '.$_POST["add"],0,1);
$pdf->SetX(30);
$pdf->Cell(25,12,'Name of Mineral/ore: '.$_POST["nom"],0,1);
$pdf->SetX(30);
$pdf->Cell(25,12,'Place of Storage: '.$_POST["Storage"],0,1);
$pdf->SetX(30);
$pdf->Cell(25,12,'Date of Registration From : '.$_POST["Date1"],0,1);
$pdf->SetX(30);
$pdf->Cell(25,12,'Date of Registration To: '.$_POST["Date2"],0,1);
$pdf->SetX(30);
$pdf->Cell(25,12,'Profession of the registrant : '.$_POST["Profession"],0,1);
$pdf->SetX(30);
$pdf->Cell(50,12,'Remark: '.$_POST["remark"],0,1);
$pdf->Output();
}
}
}
我在执行代码
时遇到此错误注意:第558行/Applications/XAMPP/xamppfiles/htdocs/MinesMineral_v3/final/connection.php中的未定义索引:nom
注意:第616行的/Applications/XAMPP/xamppfiles/htdocs/MinesMineral_v3/final/connection.php中的未定义索引:nom FPDF错误:某些数据已经输出,无法发送PDF文件
答案 0 :(得分:2)
首先,name
属性必须是
name="nom[]" // not name"nom[]"
这就是您收到undefined index
警告的原因。
其次,由于$_POST["nom"]
是数组,要获取它的字符串表示,您应该使用例如implode
:
$pdf->Cell(25,12,'Name of Mineral/ore: '.implode(', ', $_POST["nom"]),0,1);
在这种情况下,您将有项目列表除以,
。
或者您可以迭代$_POST["nom"]
并输出每个Cell
来电中的每个项目:
foreach ($_POST["nom"] as $ore) {
$pdf->Cell(25,12,'Name of Mineral/ore: ' . $ore,0,1);
}