1

With a normal SELECT in the mySQL DB I select the HTML content of the final page.

I am building a way to create pages on the fly ( as any CMS does ) and I am saving the HTML code for each page inside a specific table fo my DB.

The problem is I want the content to be multi-language. But I do not know how to SELECT html code from the DB and before printing it, working on it with PHP.

I know it's hard to understand, this is why I have an example :)

$q='SELECT * FROM pages WHERE Page="'.$page.'"';
 $r=mysql_query($q) or die(mysql_error());
     while($row = mysql_fetch_array($r)) {
      $content = $row['Content'];
       }
 return $content;
}

The Content of the variable $content, will be something like:

<div id="hello">{$foo}</div>

where {$foo} is in fact a PHP variable and must be run by the PHP code before printing the final HTML.

How can I do that? Also please consider I will have many {$foo} variables into the content, so I must find a way to replace all of them and to make the PHP working on them before printing the final HTML code.

Can you help me? :)

2
  • You can use a templating library which supports this {$var} syntax. Many do. Commented Jan 29, 2012 at 22:00
  • possible duplicate of PHP keep me from eval ;) Variables inside string - but more exact duplicates and other options exist.. Commented Jan 29, 2012 at 22:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.