RE: [Templates] MySQL Question

[prev] [thread] [next] [Date index for 2004/11/10]

From: Jason Gottshall
Subject: RE: [Templates] MySQL Question
Date: 19:32 on 10 Nov 2004
> [% FOREACH logentry =3D DBI.query("SELECT * FROM =
altpower_battery_log_tb
> 	                                WHERE  (project_code =3D "[%
item_code %]"=20
> 	                                        )
>  	                            ")%]   =20

You can't embed TT tags inside each other like that. What you want is to
interpolate a variable into your double-quoted string, like so:

[% FOREACH logentry =3D DBI.query("SELECT * FROM altpower_battery_log_tb
	                                WHERE  (project_code =3D
$item_code
	                                        )
 	                            ")%]   =20

This can actually be done without putting the field value into a
temporary value, like this:

[% FOREACH logentry =3D DBI.query("SELECT * FROM altpower_battery_log_tb
	                                WHERE  (project_code =3D
${item.item_code}
	                                        )
 	                            ")%]   =20

Hope that helps!

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

(message missing)

[Templates] MySQL Question
Shanta McBain 19:13 on 10 Nov 2004

RE: [Templates] MySQL Question
Jason Gottshall 19:32 on 10 Nov 2004

Re: [Templates] MySQL Question
Shanta McBain 17:25 on 11 Nov 2004

[Templates] MySQL Question
Shanta McBain 16:08 on 11 Nov 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52