I've got what I assume is a newbie question regarding variable interpolation. I have some code along the lines of:
function LoadDropdownItems()
{
$DBPrimaryKey=1;
// Actually it's set elsewhere, but that's not the issue
$LayoutQuery=mysql_query($LayoutQueryStatement);
$Layout=mysql_fetch_array($LayoutQuery);
$DropdownQueryStatement=$Layout['DropdownQuery'];
$DropdownQuery=mysql_query($DropdownQueryStatement);
// ...
}
Basically, I have a query statement stored in a database field, and I'm then running that query. It all works fine, except that in some cases I want to include PHP variables (such as $DBPrimaryKey) in the query statement and have them interpolated, and I can't get this to work. For example, if I have:
select DBPageID, Caption from dbpages where dbareaid=$DBPrimaryKey order by Caption;
in the database, that's what $DropdownQueryStatement gets set to. However, if I do:
$DropdownQueryStatement="select DBPageID, Caption from dbpages where dbareaid=$DBPrimaryKey order by Caption;"
it gets set to
select DBPageID, Caption from dbpages where dbareaid=1 order by Caption;
as you would expect. I've tried putting double-quotes around $Layout['DropdownQuery'], and tried putting them in the database itself, but neither of those work.
Putting it more simply, suppose I have:
$a='stuff';
$b='some $a';
$c=$b;
How do I change the third line such that the contents of $b will be interpolated and $c will wind up containing "some stuff"?
Any help would be appreciated.