EllisLab text mark
Advanced Search
     
EE Query with php-var ?
Posted: 20 March 2012 06:21 PM   [ Ignore ]
Joined: 2011-07-12
7 posts

Hello community,

I am trying to give a value to a php-var and use this later on the page in an ee-query.
Is this impossible or is there something wrong with my code ?

{exp:channel:entries channel="test" studio_id="{segment_2}"}
// a lot of irrelevant code here
<?php
 $phpvar 
"{residentie}";
 echo 
$phpvar// this works > i see the value on the page
?>
{
/exp:channel:entries}

// in this part i want to use the php-var in the query > this doesn't seem to work

{exp:query sql="SELECT entry_id FROM exp_channel_data WHERE field_id_1 = '<?php echo $phpvar; ?>' "}
        entry_id 
{entry_id} // no entry_id showed on the page
{/exp:query} 

Any advice ???
THX

 
Posted: 20 March 2012 08:02 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-15
426 posts

Actually that is not possible the way you have it now. If you set PHP to be parsed on Input, which is what you need to pass it into the query module, then the PHP variable value will not have been set yet because the entries loop will not have run yet.  You will need to put the query module code in an embed and pass in the PHP variable value to it.

 Signature 

ExpressionEngine Development | 21purple Web Studios, LLC or on Twitter @th3mus1cman