Page 1 of 1

Gettings variables to work in a MySQL template

Posted: Sun May 26, 2002 7:35 pm
by ADTLG
Well, after hours of trying this, I finally managed to get the start of my new site layout to read stuff (template) from a MySQL database. The table I put this in is caled 'templates' and has 3 fields: id, name and content.

The id is the id of the template, name the name (doh) and the content is the actual template. I only have the copyright template as a test now, which is this:

<table width=$tablewidth bgcolor=$tableborder cellspacing=$tablecellspacing cellspadding=$tablecellspadding align=center><tr><td width=100%>$font © RPG Revelation 2001 - 2002, all rights reserved</td></tr></table>

But, the result I get is this: <a href=http://www.rpgrevelation.com/layout/hom ... ome.php</a>

As you can see, the variables won't work, and to be honest, I don't have a clue on how to get them to and on IRC nobody knew either, so can anybody tell me how to get these variables to work? I don't want to use the templates with 100% HMTL, considering I'd have to change everything manually again. <img src=images/icons/icon25.gif align=absmiddle>

Posted: Sun May 26, 2002 7:54 pm
by volka
try the eval()-function

Code: Select all

eval("print("$template");");
or use preg_replace to replace certain parts of the template

Posted: Sun May 26, 2002 8:11 pm
by ADTLG
How exactly would this eval code work?

eval("print(\"$copyright[content]\");");

doesn't seem to work for me :/

EDIT: nevermind, seems to work now, thanks alot, this was eating me up from the inside :)