fpdf error and view table error

拜拜、爱过 提交于 2019-12-06 08:10:29

First, you should close all your <tr> and <td> tags. Second, you're not sending any file with your form, and hence you're getting this Undefined index: file error, so remove these lines,

$file_filename=$_FILES['file']['name'];
$target_path  =  "Newfolder1";
$image_path = $target_path . DIRECTORY_SEPARATOR . "filename";
$image_format = strtolower(pathinfo('filename', PATHINFO_EXTENSION));

So after user hits view button, you should process your form and display image like this,

// your code

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();
    }

    $sql="SELECT * FROM imagetable WHERE ID= '$_POST[search]'";
    $result = mysqli_query($con, $sql);
    if(!mysqli_query($con, $sql)){
        die( "Could not execute sql: $sql"); 
    }

    $row = mysqli_fetch_array($result);
    $image_path = $row['file'] . DIRECTORY_SEPARATOR . $row['filename'];  // path should be like this, process/upload/8/cdv_photo_001.jpg
    $image_format = strtolower(pathinfo($image_path, PATHINFO_EXTENSION));
    $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();
}

// your code
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!