Skip to content

Instantly share code, notes, and snippets.

@hemache
Created October 31, 2012 13:49
Show Gist options
  • Save hemache/3987128 to your computer and use it in GitHub Desktop.
Save hemache/3987128 to your computer and use it in GitHub Desktop.
php database image
<?php
function get_image()
{
$query = "SELECT Image FROM Mini_Article WHERE id= 4";
$result = mysql_query($query) or exit("mysql error");
$row = mysql_fetch_row($result);
$image_data = $row[0]; // Image col
return $image_data;
}
?>
<div class="image_b">
<?php
$image_data = get_image();
$data_uri = "data:image/png;base64,". base64_encode($image_data);
// استعل data uri http://en.wikipedia.org/wiki/Data_URI_scheme
printf('<img src="%s" border="1" alt="" />', $data_uri);
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment