Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

ambil gambar base64 dari database

Dekode string gambar Anda di data:image/gif;base64

<head>
<meta charset = "utf-8">
<title> Welcome </title>
<script> </script>
<style></style>
</head>
<body>
    <table border = "solid">
        <tr>
            <th> id </th>
            <th> Millitary number </th>
            <th> Fname </th>
            <th> Lname </th>
            <th> Image </th>
        </tr>
        <?php 
           $conn = mysqli_connect("localhost" , "id2549459_salamnti" , "0000000000" , "id2549459_tutorial");
            if($conn->connect_error){
                die("my connection faild" . $conn->connect_error);
            }

            $sql = "SELECT id, militry_num , firstname, lastname,image from students";
            $result = $conn->query($sql);
            if($result->num_rows > 0){
                while($row = $result->fetch_assoc()){
                    echo "<tr> <td>" . $row["id"] .  "</td> <td>"
                        . $row["militry_num"] . 
                         "</td> <td>". $row["firstname"] .
                         "</td><td>" . $row["lastname"] . "</td><td>" .
                         '<img src="data:image/gif;base64,' . $row["image"] . '" />' . 
                         "</td> </tr>";
            }
                echo "</table>";
            }
            else{
            echo "0 result" . $conn->error;
                }
              $conn->close();
        ?>
    </table>
</body>



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Mempertahankan nilai kotak teks bahkan setelah penyegaran

  2. NULL vs DEFAULT NULL vs NULL DEFAULT NULL dalam pembuatan kolom MYSQL?

  3. Dialek SQL Tidak Dikonfigurasi (Phpstorm)

  4. MySQL:perbandingan nilai integer dan bidang string dengan indeks

  5. Kesalahan hanya baca MySQL yang aneh