I'm currently having a problem with the image file which i need to call out from the database with php code by using joomla plugin (Sourcerer). But unfortunately it echo out many alien word. Is the code i use to echo out the image have some mistake?
Here is my sample code:
<?php
// Get default database object
$db =JFactory::getDBO();
// Get a new JDatabaseQuery object
$query = $db->getQuery(true);
// Build the query
$query = "
SELECT *
FROM ".$db->quoteName('college')."
WHERE ".$db->quoteName('userid').'='. $db->quote('0123').";
";
// Set the query for the DB oject to execute
$db->setQuery($query);
// Get the DB object to load the results as a list of objects
$results = $db->loadObjectList();
if($results){
foreach($results as $result){
echo "<label for='collegeid' class='field prepend-icon'>";
echo "<input type='text' id='collegeid' name='collegeid' class='gui-input' value='$result->collegeid' placeholder='College ID...'>";
echo "<label for='collegeid' class='field-icon'><i class='fa fa-user'></i></label>";
echo "</label>";
echo "</div><!-- end section -->";
echo "</div><!-- end .frm-row section -->";
echo "<div class='section'>";
echo "<label for='collegefullname' class='field prepend-icon'>";
echo "<input type='text' name='collegefullname' id='collegefullname' class='gui-input' value='$result->fullname' placeholder='College's full name...'>";
echo "<label for='collegefullname' class='field-icon'><i class='fa fa-envelope'></i></label>";
echo "</label>";
echo "</div>";
echo "
<div class='section'>
<label for='collegeshortname' class='field prepend-icon'>
<input type='text' name='collegeshortname' id='collegeshortname' class='gui-input' value='".$result->shortname."' placeholder='College's short name...'>
<label for='collegeshortname' class='field-icon'><i class='fa fa-envelope'></i></label>
</label>
</div><!-- end section -->
<div class='section'>
<label for='description' class='field prepend-icon'>
<textarea class='gui-textarea' id='description' name='description' value='".$result->description."' placeholder='Description...'>".$result->description."</textarea>
<label for='comment' class='field-icon'><i class='fa fa-comments'></i></label>
<span class='input-hint'>
Please write the description of the college...
</span>
</label>
</div><!-- end section -->
<div class='section'>
<h3>Upload College's Logo: </h3><br/>";
header("Content-type: image/jpeg");
echo $result->logo;
.....
The result can be view at here: http://demo.matedis.com/add-and-edit-college