mercredi 5 juin 2019

Multiple a number if variable is yes [duplicate]

This question already has an answer here:

I am trying to insert into a database the current rate multiplied by the mileage with an if statement. I need the mileage to be doubled if the journey is a return journey.

Tried some code which is posted below but struggling to make it work as it just takes the else line of code without considering if its no a return.

returntrip is posted from a form with the value of Y for yes, N for no. I want amount to equal multiply the rate which is posted from the form by the mileage but the mileage could be exact as entered on the form if not a return journey or multiplied if a return journey.

 $tripis = $returntrip;
 if ($tripis="Y"){
     $checkmiles = $mileage * 2;
 } else { 
     $checkmiles = $mileage;
 }

 $amount = $rate * $checkmiles;

The above code just inserts the else regardless if the returntrip value is Y or N.

Aucun commentaire:

Enregistrer un commentaire