Categories > TinyButStrong general >

Pass values throught template levels

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jorge
Date: 2004-01-28
Time: 18:58

Pass values throught template levels

Hi,

Here's my file structure:
/query.php
/query.php.tpl
/result.php
/result.php.tpl
/templates/resultat.inc.php   (used by result.php.tpl)
/templates/resultat.inc.php.tpl

I have a first couple of files
query.php file
HTML:
<form name="form1" method="POST" action="result.php">
   <select name="animal">
       <option value="100">Dog</option>
       <option value="200">Cat</option>
   </select>
</form>

Then a result.php file
(nothing special..but the solution is perhaps to include on this file..)

and result.php.tpl
where I have
[tbs_include.onshow;script=templates/resultat.inc.php;getob]

----

resultat.inc.php   and resultat.inc.php.tpl are the files where I do my SQL query and display the result

Eveything works fine: file incluse works!

The problem I have know, is that i'm trying to pass values from variables posted by my from on query.php file to resultat.inc.php file (where i do the query with conditions)


So from templates/resultat.inc.php I would like to do a query like
select * from mytable
where type= $animal

I've done some tests and I'm able to pass values from
query.php to result.php

but not to transmit it to
templates/resultat.inc.php (file I call from result.php)

Someone could help?

Jorge
By: Skrol29
Date: 2004-01-28
Time: 23:48

Re: Pass values throught template levels

Hi Jorge,

In the sub-script, you have to reach the global variables using $GLOBALS.

This is because the sub-script is called from a function context and not the main script context.
By: Jorge
Date: 2004-01-29
Time: 11:24

Re: Pass values throught template levels


It effectly works with

select * from mytable
where type= $GLOBALS['animal']

Thanks