Variable within a Variable
| From: | bob pilly | Date: | Mon, 10 Apr 2006 01:54:46 +0000 |
| Subject: | Variable within a Variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-233644@lists.php.net to get a copy of this message | ||
Hi All
Im trying to store a document template in mysql that has php var names within it and then find it
in the datebase and print it out with the var names replaced with the var values.
e.g i have this stored
Dear $title $name
we would like to......
I declare the vars $title and $name
$title = 'Mr';
$name = 'Test';
//retrieve the stored template
$query = "select template from letters";
$result = mysqli_query($dblink,$query);
if($row = mysqli_fetch_array($result)){
print $row['template'];
}
i would expect that to print:
Dear Mr Test
we would like to......
but it doesnt it prints out
Dear $title $name
we would like to......
can someone point out where i am going wrong? Is this actually possible and if so im picking ive
go the syntax wrong?
Thanks for any help in advance!
Cheers
Bob
---------------------------------
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.