Mysql
 sql >> Base de données >  >> RDS >> Mysql

Problèmes d'affichage des images blob

Essayez ceci :

<?php

    //Connect to the database
  $databasehost = "YOUR DATABASE HOST";
  $databasename = "YOUR DATABASE NAME";
  $databaseusername ="YOUR DATABASE USERNAME";
  $databasepassword = "YOUR DATABASE PASSWORD";

  $con = mysqli_connect($databasehost, $databaseusername, $databasepassword, $databasename) or die(mysqli_error($con));
  mysqli_set_charset ($con, "utf8");

$sql = "SELECT image, titulo, tecnica, medidas FROM upload;";
$res = mysqli_query($con, $sql);
$result = array();

while($row = mysqli_fetch_array($res)) {
array_push($result,
array(
'image'=>base64_encode($row[0]),
'titulo'=>$row[1],
'tecnica'=>$row[2],
'medidas'=>$row[3]
));
}
echo json_encode(array($result));

mysqli_close($con);

Cela imprimera vos données comme ceci :

J'espère que cela aide! Bonne chance! Bon codage !