CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 passing variables to html?

Print topic Send  topic

Author Message
ulrisa

Posts: 8
Posted: 07/03/2008, 12:43 PM

Hi. I guess this is a stupid question..

I need to pass a value from php to html..

Ive looked for info and foud this but it doesent work.

What i want is that welcome shall contain the logged in users id but it wont work att all why?

Really need help!

html {welcome}

php
global $Tpp;
$Tpp->SetVar('welcome', $_SESSION[UserID]);
View profile  Send private message
datadoit
Posted: 07/03/2008, 6:23 PM

ulrisa wrote:
> Hi. I guess this is a stupid question..
>
> I need to pass a value from php to html..
>
> Ive looked for info and foud this but it doesent work.
>
> What i want is that welcome shall contain the logged in users id but it wont
> work att all why?
>
> Really need help!
>
> html {welcome}
>
> php
> global $Tpp;
> $Tpp->SetVar('welcome', $_SESSION[UserID]);
> ---------------------------------------

Should be $Tpl, not $Tpp.
ulrisa

Posts: 8
Posted: 07/04/2008, 2:25 AM

Can i use another variable name or is $Tpl the onley allowed?
View profile  Send private message
ulrisa

Posts: 8
Posted: 07/04/2008, 2:25 AM

Can i use another variable name or is $Tpl the onley allowed?
View profile  Send private message
jjrjr1


Posts: 942
Posted: 07/04/2008, 2:39 AM

Hi

The value must be $Tpl and you must set it as global.

The reason is thet $Tpl is the object that is defined to be the HTML template the PHP code is placing values into.

So is you have the string {welcome} in your HTML the setvar method for $Tpl will replace it.

EG:

HTML:

<a href="code.php?value={welcome}>Say Hello</a>

The PHP code:

global $Tpl;
$Tpl->SetVar('welcome', $_SESSION[UserID]);

will replace all occurences of {welcome} to the value of $_SESSION[UserId]);

Does that make sense and help a little.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
ulrisa

Posts: 8
Posted: 07/04/2008, 3:10 AM

Thanks, that was very helpful.

But then ihave a problem $Tpl is already used in my index.php can i declare another variable in the HTML template?

Ulrik

View profile  Send private message
jjrjr1


Posts: 942
Posted: 07/04/2008, 6:21 AM

Yes $Tpl is always used. It is in every php file.

$Tpl is NOT the variable in the HTML template. It IS the HTML template.

$Tpl is an object that contains the entire template. setvar() is a method for the $Tpl object.

$Tpl->SetVar() with replace in the HTML the value specified like in the example I posted above.
You can put any number or {xxx} {xyyy} you want into the HTML code itself and setvar() will replace it with whatever value you specify.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.