[?] parse variable to exec php/smarty code
| From: | Alexey Rodionov | Date: | Fri, 14 Dec 2001 13:56:57 +0000 |
| Subject: | [?] parse variable to exec php/smarty code | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2291@lists.php.net to get a copy of this message | ||
Hello.
How could I parse variable to execute the code inside it?
I need that because I select articles from database into a variable.
Articles contain <php> code inside.
Example:
// Select article from database:
<php
function get_article ($Article_ID) {
if (isset($Article_ID)) {
$result = mysql_query("SELECT * FROM tbl_article WHERE
Article_ID='$Article_ID'");
}
$article = mysql_fetch_array($result);
return ($article);
}
%>
That was from my main script. This selected article has the foolowing
code inside:
...
<?php
include ("connection.php");
$sqlcollection = "SELECT collection, collection_id FROM tbl_collection";
$rescollection = mysql_query($sqlcollection);
$rowcollection = mysql_fetch_array($rescollection);
print "<option value=\"default.htm#\" selected>collection</option>";
while (@$rowcollection = mysql_fetch_array($rescollection)) {
echo "<option
value=\"/search/catalog.php?collection=".$rowcollection["collection_id"]."\">".$rowcollection["collection"]."</option>\n";
}
print "</select>";
?>
...
As you can see I need this "select" menu organize dinamically.
Or even I wish to insert in one of the articles such a code:
<?php
include ("news.php");
?>
How do I have to organize these things? Smarty insert just in the
output without compiling those codes..
Please help.
Best regards,
Alexey