Created
October 31, 2012 13:49
-
-
Save hemache/3987128 to your computer and use it in GitHub Desktop.
php database image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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