How to use If Condition in PHP ?

Stimulsoft Reports.PHP discussion
Post Reply
latika
Posts: 6
Joined: Wed Aug 03, 2011 9:10 am
Location: India

How to use If Condition in PHP ?

Post by latika »

Hi, I need some help figuring out how to have a only print, if the choices within then have data. The evaluation that gives the data is done using if statements. This is the result of the data in the system.

Agents=24,36,34 (these is evaluated using if statements)
Campaigns=0
Team=1


Could you Guide me on how to use IF conditional statements or other conditions like Switch,Choose ?

eg.

if(Agents!="")
{
select * from table where agentID='23'
}
else if(Campaigns!="" || Team!=1)
{
select * from table where CampaignsID='23'
}


Image

How do I go about doing so? or any other solution.


Thank You,
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

How to use If Condition in PHP ?

Post by HighAley »

Hello.
latika wrote:Hi, I need some help figuring out how to have a only print, if the choices within then have data. The evaluation that gives the data is done using if statements. This is the result of the data in the system.

Agents=24,36,34 (these is evaluated using if statements)
Campaigns=0
Team=1


Could you Guide me on how to use IF conditional statements or other conditions like Switch,Choose ?

eg.

if(Agents!="")
{
select * from table where agentID='23'
}
else if(Campaigns!="" || Team!=1)
{
select * from table where CampaignsID='23'
}


Image

How do I go about doing so? or any other solution.
Please, try to use this expression

Code: Select all

 select * from table where {Switch(Agents!="", "agentID='23'", Agents=="" && (Campaigns!="" || Team!=1), CampaignsID='23')}
Agents, Campaigns and CampaignsID must be variables.

Thank you.
Berenice29
Posts: 4
Joined: Thu Oct 20, 2011 3:43 am
Location: london

How to use If Condition in PHP ?

Post by Berenice29 »

I want to know if there is a way to use something like this:

$t1=1;
$t2=2;
$t3="$t1>$t2";

if($t3)
echo "Greater";
else
echo "Smaller";
This will evaluate to true as $t3 is a string, but that's wrong!!!

So is there a way to include the if condition inside string.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

How to use If Condition in PHP ?

Post by HighAley »

Hello.

Where do you want to write a condition exactly in the SQL query or in the report expression?

Thank you.
Post Reply