Re: [?] parse variable to exec php/smarty code
| From: | Monte Ohrt | Date: | Fri, 14 Dec 2001 14:29:09 +0000 |
| Subject: | Re: [?] parse variable to exec php/smarty code | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2292@lists.php.net to get a copy of this message | ||
Write a custom function that does an eval() on your variable.
{eval var=$article_text assign=foo}
(optionally assign to var foo?)
Alexey Rodionov wrote:
>
> 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
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/