Created
November 8, 2011 14:04
-
-
Save rogerlsmith/1347797 to your computer and use it in GitHub Desktop.
Displays an image stored in mysql to a webpage
This file contains 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
<!-- html; put this in your code where you want to display the image stored in the database --> | |
<a href="index.php"><img src="data:image/png;base64,<?php echo base64_encode($MyClass->getLogo())?>" alt="Logo" width="233" height="65" /></a> | |
<!-- php function that queries the database and returns the blog image data --> | |
public function getLogo() | |
{ | |
if ($this->getId()) | |
$query = "SELECT `logo` FROM Logos WHERE `logo_id` = '{$this->getId()}' LIMIT 1"; | |
else | |
$query = "SELECT `logo` FROM Logos WHERE `logo_id` = '1' LIMIT 1"; | |
$result = mysql_query($query); | |
if ($result) | |
$row = mysql_fetch_array($result); | |
else | |
return NULL; | |
return ($row['logo']); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment