PDA

View Full Version : using a variable and conditional in template


da prez
08-20-2004, 07:08 PM
i wrote a simple query that returns a numeric value or 1, 2, or 3 etc.

what i want to do is use this variable to make a conditional.
$string6 is my variable and it does return proper #
can i use this variable in a conditional within a template to do something like this ??

example:
<if $string6="1">Hello</if>

<if $string6="2">Goodbye</if>

how would i go about it ?

i have a shoutcast radio station up,
and based on which dj is online i want to show diff info.

da prez
08-20-2004, 07:32 PM
oops i think this is is in wrong forum.

sorry for that.

Colin F
08-21-2004, 04:26 AM
i wrote a simple query that returns a numeric value or 1, 2, or 3 etc.

what i want to do is use this variable to make a conditional.
$string6 is my variable and it does return proper #
can i use this variable in a conditional within a template to do something like this ??

example:
<if $string6="1">Hello</if>

<if $string6="2">Goodbye</if>

how would i go about it ?

i have a shoutcast radio station up,
and based on which dj is online i want to show diff info.
yes, you can use $string6 (allthough I would rename it so that you know what's in it, if you edit the code again in a few month's time...)

Try this:
<if condition="$string6==1">Hello
<else />
<if condition="$string6==2">Goodbye
</if>
</if>

da prez
08-21-2004, 03:14 PM
thanks much,

i had actually went with the if condition statement, and the double ==,
but i put the quotes in wrong spot <if condition=$string6=="1"> or <if condition $string6=="1">
i had been up and down all the combinations i could think of, but the one that works.
always something simple that gets me..... LOL !!

problem solved.

oh yeah, and i am gonna rename it, when i get some more of it sorted out,
i had a couple of probs with variables clashing.

thanks again.