mardi 28 juin 2016

How can I make my DB images be displayed in the table?

My table at the moment is like this: http://imgur.com/ZMb6Ade

The images go directly into the DB, so there isn't any file in the server for the images to go to be stored.

Select3.php:

<?php  
 $db_host        = 'localhost';
 $db_user        = 'root';
 $db_pass        = '';
 $db_database    = 'crc'; 
 $output = ''; 
    $db = new PDO('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass);
    $result = $db->prepare("SELECT * FROM pulseiras ORDER BY ref ASC ");
    $result->execute();     
$output .= '  
  <div class="table-responsive">  
       <table class="table table-bordered">  
            <tr>  
                 <th width="10%">REF</th> 
                 <th width="25%">Nome</th> 
                 <th width="25%">Preço</th>  
                 <th width="25%">Imagem</th> 
            </tr>';  
 if (count($result) > 0)   
{  
 for($i=0; $row = $result->fetch(); $i++){ 
       $output .= '  
            <tr>  
                 <td>'.$row["ref"].'</td>  
                  <td class="nome" data-ref1="'.$row["ref"].'" contenteditable>'.$row["nome"].'</td>  
                  <td class="preco" data-ref2="'.$row["ref"].'" contenteditable>'.$row["preco"].'</td> 
                  <td class="imagem" data-ref3="'.$row["ref"].'" contenteditable><img src="data:image/jpeg;base64,'.base64_encode( $row['imagem'] ).'"/></td> 
                 <td><button type="button" name="delete_btn" data-ref5="'.$row["ref"].'" class="btn btn-xs btn-danger btn_delete">X</button></td>  
            </tr>  
       ';  
  }  
  $output .= '  
       <tr>  
            <td></td>  
            <td id="nome" contenteditable></td>  
            <td id="preco" contenteditable></td>  
            <td id="imagem" contenteditable></td>    
       </tr>  
  ';  
}  
else  
{  
     $output .= '<tr>  
                      <td colspan="4">Data not Found</td>  
                 </tr>';  
}  
$output .= '</table>  
     </div>';  
echo $output;  
?>  

Image type is BLOB. Any help is appreciated.

Aucun commentaire:

Enregistrer un commentaire