Output PHP from MySQL Database
Posted: Mon Aug 06, 2007 2:32 pm
I simply want to out put a PHP code stored in the database into my page. I've tried:
I am trying to output:
But all it does is show that code as plain text. How can I fix this so that processes the php?
Thanks in advance!
Luke
Code: Select all
$sql = "SELECT page_id, page_name, page_desc, page_content " .
"FROM pages WHERE page_id=" . $_GET['p'];
$result = mysql_query($sql, $conn);
$row = mysql_fetch_array($result);
$page_content = $row['page_content'];
eval($page_content);Code: Select all
$sql = "SELECT * FROM calendar ORDER BY date";
$result = mysql_query($sql, $conn);
echo "<table border=\"0\" cellpadding=\"2\" id=\"calendar_table\">";
echo "<tr id=\"table_header\">";
echo "<td width=\"100px\">Date</td>";
echo "<td width=\"200px\">Location</td>";
echo "<td width=\"60px\">Time</td>";
echo "<td width=\"300px\">Description</td>";
echo "</tr>";
while ($row = mysql_fetch_array($result)) {
echo "<tr class=\"table_row\">";
echo "<td width=\"100px\">" . $row['date'] . "</td>";
echo "<td width=\"200px\">" . $row['location'] . "</td>";
echo "<td width=\"60px\">" . $row['time'] . "</td>";
echo "<td width=\"300px\">" . $row['details'] . "</td>";
echo "</tr>";
}
echo "</table>";Thanks in advance!
Luke