Returning php from database and rendering the code
<p>Im managing my web content a DB. When you hit a certian page, a query is made to the db to return the content for that page. Usualy I just store static html as a string and when it's returned from the db and placed into the webpage, it renders correctly. But now, some of the content actually contains php and when returned, the php is displayed as text. I looked in the eval() function but doesnt seem to work for me, or perhaps I'm using it wrong.</p>

<p>Here is and example of my code:</p>

<pre><code>mysql_select_db("default_DB1", $con);

                $result = mysql_query("SELECT * FROM submenus WHERE active = '1' and menu_id='" . $_GET['article'] . "'");

    echo "&lt;ul&gt;\n";
                $counter = 1;
                while($row = mysql_fetch_array($result))
                {
                        echo "&lt;li&gt;&lt;a href=\"#tabs-" . $counter . "\" onclick=\"storySize('tabs-" . $counter . "');\"&gt;" . $row['submenu_name'] . "&lt;/a&gt;&lt;/li&gt;\n";
                        $counter = $counter + 1;                    
                }
                echo "&lt;/ul&gt;\n";

                $counter = 1;
                $result2 = mysql_query("SELECT * FROM submenus WHERE active = '1' AND menu_id='" . $_GET['article'] . "'");
                while($row2 = mysql_fetch_array($result2))
                {
                        echo "&lt;div id=\"tabs-" . $counter . "\" style=\"height:100%; overflow:visible;\"&gt;" . str_replace("*#*","'",$row2['submenu_content']) . "&lt;/div&gt;\n";                      
                        $counter = $counter + 1;
                }

                mysql_close($con);
</code></pre>

<p>Then the content returned is:</p>

<pre><code>&lt;table width="100%"&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Username: &lt;/td&gt;
&lt;td align="left"&gt;&lt;input type="text" id="txtUsername" name="txtUsername" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;Password: &lt;/td&gt;
&lt;td align="left"&gt;&lt;input type="text" id="txtPassword" name="txtPassword" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User Type&lt;/td&gt;&lt;td&gt;&lt;select id="ddlUserType" name="ddlUserType"&gt;

$con = mysql_connect("domain.com","username","pwd");
if (!$con)
  {
  die(#*#Could not connect: #*# . mysql_error());
  }

mysql_select_db("default_DB1", $con);

$result = mysql_query("SELECT * FROM user_types WHERE user_type_name &lt;&gt; #*#Admin#*# and active = #*#1#*#");

while($row = mysql_fetch_array($result))
  {
  echo "&lt;option value=\"" . $row[#*#user_type_id#*#] . "\"&gt;" . $row[#*#user_type_name#*#] . "&lt;/option&gt;";
  }

mysql_close($con);

&lt;/select&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;&lt;/td&gt;
&lt;td align="left"&gt;&lt;input type="button" id="txtReg" name="txtReg" value="Register" onclick="alert(*#*plaka*#*);"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>
