This is a really tough question to ask. He is my issue/question.
Is it possible to put a PHP function inside a MySQL table/cell and have the function run normally when called via a PHP query. If so How can I do it?
Here is my query code:
$recent_query = "SELECT * FROM `recently-added` ORDER BY `created` DESC LIMIT 4";
if(!$recent_query_result = $con->query($recent_query)){
die('There was an error running the query [' . $con->error . ']');
}
Here is my loop code that displays the results of the query:
while($row = $recent_query_result->fetch_assoc()) {
echo '<div class="col-md-3 col-sm-6 md-margin-bottom-40">
<div class="easy-block-v2">
<div class="easy-bg-v2 rgba-' . $row['color'] . '">New</div>
<img class="img-bordered" alt="' . $row['image-alt'] . '" src="' . $row['image'] . '">
<h3><i class="fa fa-smile-o"></i> ' . $row['site-name'] . '</h3>
<!-- Begin Recently Added Footer Description -->
</div>
</div>';
}
In my database and inside the table 'recently-added' I have a column named 'site-name'. I iterate through the loop and display the results onto my page. In the site name cell I put my PHP function for each record. That function is:
<?php star5(); ?>
When I refresh the page and look at where the function should be called it's a blank space. Nothing there. When I go to look at the source code to see if there is an error it shows me the exact characters that I put into the cell. It places the text onto the page and the server does not run the script or interpret the function.
Here is an image of the table in the database. This is in regard to te column 'site-name':
http://i.imgur.com/0XWBqtR.jpg
Been trying to fix this for almost 4 hours now. As always thanks in advance!
EDIT: Here is the function it's self
function star5() {
echo '<li><i class="color-green fa fa-star"></i></li>
<li><i class="color-green fa fa-star"></i></li>
<li><i class="color-green fa fa-star"></i></li>
<li><i class="color-green fa fa-star"></i></li>
<li><i class="color-green fa fa-star"></i></li>';
}