mardi 3 mars 2015

Php if statement logic with multiple else if. How to make it easy

I am fumbled in between if and else if statement in calculation


Have multiple variable - prime been



Fuel type = (Petrol, Diesel, CNG)


Price = (<600, 600 - 999, > 1000)



Using Php



<?php
$a = $this->prodDet->v_price;
$h = $this->prodDet->v_fuel_type;
$x=.02166;
$y=.02143;
$z=.02143;


i intend to calculate multiple values subject to combination of price and fuel type


My Question is How to create if statement for doing calculation



if ($h = Petrol and $a < 600)
{
$c=$a*$z*.85;
else
{
if ($h = Diesel and $a < 600)
{
$c=$a*$y*.85;
else
{
if ($h = CNG and $a < 600)
{
$c=$a*$x*.85;
else
{
$c=$a*$x*$y*.85;
if ($h = Petrol and 600 > $a < 1000)
{
$c=$a*$y*$z*.85;
{
else
}
if ($h = Diesel and 600 > $a < 1000)
{
else
}
if ($h = CNG and 600 > $a < 1000)
{
else
}
if ($h = Petrol and $a > 1000)
{
else
}
if ($h = Diesel and $a > 1000)
{
else
}
if ($h = Diesel and $a > 1000)
{
else
}


Can someone guide to make it easy


Aucun commentaire:

Enregistrer un commentaire