Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

if else fuction 05.02.2015 10:00

Dear all, I have the fuction. If epan>2 then I want to see the results in the result layout else I want to have an error message asking user to insert new values. Unfortunately I don't know what to put after "else"

This is the half of the code:

$aferesi=$mashali-$omos;
$afer=$aferesi/2;
$epal=sires/afer;
if ($epal > "2") {
$p=$sires-$aferesi;
$p2=$p/2;
$x=$afer-$p2;
}
else {
I want to see a message error or a pop up error!!!??
}

Re: if else fuction 05.02.2015 11:18

Hi,
if you were printing a single result, like $result, you could use that approach to set $result with the if/else structure:

if($epal>2){
//calculations
$result=376;
}

else{

$result="Error:Message";
}


but looking at your code, seems you are calculating several results, so we'd use this solution instead:


At your exit layout, create the two sections (real results, and error message). Enclose each one inside a div and set a different style for each one:

//real results

...div style="display:##displayreal##"


//here your result section..close div


//error section

..div style="display:##displayerror##"

//here your error section...close div



and now you can set at the code the display of each section according to your condition:


//calculations

if($epal>2){

$displayreal="block";
$displayerror="none";
}

else{
$displayreal="none";
$displayerror="block";

}


Please let us know if you need further help with this.


Thanks, regards
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback