$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();
this is two pages and error is coming out Undefined index:
file Undefined index: file so please try to point out the mistake because main error is showing when i added the image field then the error is started popping out.
- I am trying to fetch the image from the database and trying to show it in PDF format.

 
     
    