【发布时间】:2015-12-26 21:19:56
【问题描述】:
$sqlinsert="SELECT * FROM imagetable ";
$result = mysqli_query($con, $sqlinsert);
echo "<table border='1'>";
echo "<tr>
<th>ID</th>
<th>School Code</th>
<th>Category</th>
<th> School name </th>
<th> School Address </th>
<th> School name </th>
</tr>";
while($row = mysqli_fetch_assoc($result)){
$id= $row['ID'];
echo "<tr>
<td>";
echo $row['ID'];
echo "<td>";
echo $row['category'];
echo "<td>";
echo $row['sname'];
echo "<td>";
echo $row['sadd'];
echo "<td>";
echo $row['filename'];
echo "<td>";
?>
<form name="form" method="POST" action="parentssubmit.php">
<input type="hidden" value="<?php echo $id;?>" name="search">
<input type="submit" value="View" name="View">
</form>
<?php }
echo "</td></tr>";
echo "</table>";
========================================================================
if (isset($_POST['View']) ){
$pdf=new fpdf();
$pdf->ADDPage();
$pdf->setfont('Arial','B', 16);
$pdf->Cell(40,10, 'sname',1,0,'c');
$pdf->Cell(40,10, 'sadd',1,0,'c');
$pdf->Cell(40,10, 'category',1,0,'c');
$pdf->Cell(40,10, 'scode',1,0,'c');
$con = mysqli_connect("localhost","root","","school");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$file_filename=$_FILES['file']['name'];
$target_path = "Newfolder1";
$image_path = $target_path . DIRECTORY_SEPARATOR . "filename";
$image_format = strtolower(pathinfo('filename', PATHINFO_EXTENSION));
$sql="SELECT * FROM imagetable WHERE ID= '$_POST[search]'";
$result = mysqli_query($con, $sql);
if(!mysqli_query($con, $sql)){
die( "Could not execute sql: $sql");
}
// build the data array from the database records.
While($row = mysqli_fetch_array($result)) {
$pdf->Cell(40,10, $row['sname'],1,0,'c');
$pdf->Cell(40,10, $row['sadd'],1,0,'c');
$pdf->Cell(40,10, $row['category'],1,0,'c');
$pdf->Image($image_path,50,100,50,20,$image_format);
$pdf->ln();}
}
$pdf->output();
这是两页,出现错误未定义索引:
文件未定义索引:文件所以请尝试指出错误,因为当我添加图像字段时显示主要错误,然后开始弹出错误。
- 我正在尝试从数据库中获取图像并尝试以 PDF 格式显示它。
【问题讨论】:
-
您在哪里得到这个错误?指出出现此错误的行
-
首先关闭你所有的
td标签echo "</td><td>..." -
@RajdeepPaul 我在 $file_filename=$_FILES['file']['name']; 的第二页上收到此错误$pdf->Image($image_path,50,100,50,20,$image_format);
-
您也尝试以这种形式上传文件?您没有文件输入,并且没有正确设置表单来执行此操作。
-
我正在尝试从数据库中获取图像并尝试以 pdf 格式显示它